QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#117640#6630. Triangle Collectionsomethingnew#0 18ms3624kbC++231.5kb2023-07-01 21:21:412024-05-31 18:46:45

Judging History

你现在查看的是最新测评结果

  • [2024-05-31 18:46:45]
  • 评测
  • 测评结果:0
  • 用时:18ms
  • 内存:3624kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-01 21:21:41]
  • 提交

answer

//  ↘ ⬇ ⬇ ⬇ ⬇ ⬇ ↙
//  ➡ @roadfromroi ⬅
//  ↗ ⬆ ⬆ ⬆ ⬆ ⬆ ↖
#include <iostream>
#include "vector"
#include "algorithm"
#include "numeric"
#include "climits"
#include "iomanip"
#include "bitset"
#include "cmath"
#include "map"
#include "deque"
#include "array"
#include "set"
#define all(x) x.begin(), x.end()
using namespace std;
#define int long long
void solve() {
    int n, q;
    cin >> n >> q;
    vector<int> a(n), ac;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < q; ++i) {
        int x, c;
        cin >> x >> c;
        x--;
        a[x] += c;
        ac = a;
        int lft = 0;
        int res = 0;
        for (int j = 0; j < n; ++j) {
            int pp = min(lft, a[j] / 2);
            res += pp;
            lft -= pp;
            a[j] -= pp * 2;
            pp = a[j] / 3;
            res += pp;
            a[j] -= pp * 3;
            if (a[j] == 2) {
                for (int k = j+1; k <= j * 2; ++k) {
                    if (a[k]) {
                        a[k]--;
                        a[j] = 0;
                        res++;
                        break;
                    }
                }
            }
            lft += a[j];
        }
        cout << res << '\n';
        a = ac;
    }
}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int t = 1;
    while (t--) {
        solve();
    }
}
/*

 */

详细

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 5
Accepted
time: 0ms
memory: 3512kb

input:

1 23
1485
1 -12
1 -30
1 -20
1 6
1 24
1 5
1 31
1 14
1 -34
1 -22
1 -45
1 37
1 46
1 9
1 22
1 -9
1 9
1 -46
1 -47
1 39
1 36
1 -36
1 50

output:

491
481
474
476
484
486
496
501
489
482
467
479
495
498
505
502
505
490
474
487
499
487
504

result:

ok 23 numbers

Test #2:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

12 1
13 79 59 21 32 13 85 40 74 15 49 56
3 31

output:

189

result:

ok 1 number(s): "189"

Test #3:

score: -5
Runtime Error

input:

50 1995
3 2 3 0 3 0 5 2 2 2 3 0 4 5 4 4 3 0 1 0 5 5 3 4 3 3 1 1 4 5 5 4 1 1 3 1 4 2 1 3 4 1 5 5 0 3 0 3 4 3
49 1
48 -2
45 3
49 0
31 -4
13 0
15 -2
48 0
38 -2
8 0
48 3
12 1
22 -4
7 -5
5 -1
3 1
15 -2
37 -4
39 -1
24 -2
11 2
35 -2
17 -1
41 -2
20 5
8 0
18 0
26 -3
25 -3
49 -5
31 4
46 -2
38 0
42 3
16 -4
5 3...

output:


result:


Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #28:

score: 0
Wrong Answer
time: 17ms
memory: 3548kb

input:

1999 2000
1 1 1 1 0 2 0 2 1 0 2 1 2 2 2 1 2 0 0 1 2 2 0 1 0 1 0 2 0 0 2 1 1 1 1 0 1 2 1 2 1 1 1 1 1 0 2 2 0 2 1 1 2 0 0 2 0 0 2 1 2 0 0 1 1 2 0 2 2 2 1 2 0 2 1 2 0 1 2 2 2 1 1 2 1 1 1 1 0 0 1 1 0 1 2 1 0 0 2 0 2 2 2 0 1 1 2 0 0 1 0 0 2 1 2 1 2 0 1 1 2 2 0 0 1 2 2 1 2 1 2 2 2 0 0 1 1 2 1 1 2 2 2 2 2 ...

output:

656
656
656
657
657
657
657
656
656
656
656
657
658
657
658
658
657
657
658
658
657
656
657
656
656
656
657
657
657
657
658
657
658
657
658
657
656
656
656
657
657
656
657
658
658
658
658
658
658
657
657
657
657
657
657
657
657
658
657
657
657
657
657
656
656
655
656
655
655
655
655
655
655
655
654
...

result:

wrong answer 1st numbers differ - expected: '660', found: '656'

Subtask #4:

score: 0
Wrong Answer

Test #35:

score: 0
Wrong Answer
time: 18ms
memory: 3624kb

input:

2000 1999
0 1 0 3 0 1 0 0 0 0 0 0 0 2 0 0 0 0 3 1 1 0 2 0 0 3 0 0 0 0 0 4 0 0 1 0 1 0 0 0 0 1 2 1 0 0 0 0 7 0 1 3 1 0 1 1 0 3 2 1 0 1 1 3 3 1 0 2 0 0 0 0 0 0 0 0 1 0 0 0 2 0 0 0 0 0 1 2 3 0 1 0 3 3 0 0 0 0 1 0 1 2 0 0 2 2 0 1 2 1 2 0 0 0 1 1 0 1 2 0 0 0 0 2 0 5 0 0 0 0 0 1 0 0 2 0 1 2 0 1 0 0 0 2 0 ...

output:

663
663
663
663
663
664
663
664
663
664
663
664
663
664
663
664
663
664
663
664
663
664
663
664
663
664
663
664
663
663
663
664
663
664
663
664
663
663
664
664
663
663
663
663
662
662
662
662
661
662
662
662
662
662
662
662
662
662
662
663
662
663
662
663
662
663
663
663
663
663
663
663
663
662
662
...

result:

wrong answer 1st numbers differ - expected: '666', found: '663'

Subtask #5:

score: 0
Skipped

Dependency #1:

0%