QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#400157#6630. Triangle CollectionSorahISA0 16ms3632kbC++202.1kb2024-04-27 02:29:312024-04-27 02:29:31

Judging History

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

  • [2024-04-27 02:29:31]
  • 评测
  • 测评结果:0
  • 用时:16ms
  • 内存:3632kb
  • [2024-04-27 02:29:31]
  • 提交

answer

#ifndef SorahISA
#define SorahISA
#include SorahISA __FILE__ SorahISA

void solve() {
    int N, Q; cin >> N >> Q;
    
    vector<int> C(N+1);
    for (int i = 1; i <= N; ++i) cin >> C[i];
    
    for (int q = 1; q <= Q; ++q) {
        int l, d; cin >> l >> d, C[l] += d;
        
        int ans = 0;
        for (int i = 1, j = 0, sum = 0; i <= N; ++i) {
            while (j <= min(N, 2*i-1)) sum += (C[j++] == 1);
            int tmp = min(C[i] / 2, (C[i] + sum) / 3);
            ans += tmp, sum = C[i] + sum - 3 * tmp;
        }
        cout << ans << "\n";
    }
}

int32_t main() {
    fastIO();
    
    int t = 1; // cin >> t;
    for (int _ = 1; _ <= t; ++_) {
        solve();
    }
    
    return 0;
}

#else

#ifdef local
#define _GLIBCXX_DEBUG 1
#endif
#pragma GCC optimize("Ofast", "unroll-loops")
#include <bits/stdc++.h>
using namespace std;

using i64 = long long;
#define int i64
using f80 = long double;
#define double f80
using pii = pair<int, int>;
template <typename T> using Prior = std::priority_queue<T>;
template <typename T> using prior = std::priority_queue<T, vector<T>, greater<T>>;

#define eb emplace_back
#define ef emplace_front
#define ee emplace
#define pb pop_back
#define pf pop_front
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
#define SZ(x) ((int)(x).size())

#ifdef local
#define fastIO() void()
#define debug(...) \
    fprintf(stderr, "\u001b[33m"), \
    fprintf(stderr, "At [%s], line %d: (%s) = ", __FUNCTION__, __LINE__, #__VA_ARGS__), \
    _do(__VA_ARGS__), \
    fprintf(stderr, "\u001b[0m")
template <typename T> void _do(T &&_t) { cerr << _t << "\n"; }
template <typename T, typename ...U> void _do(T &&_t, U &&..._u) { cerr << _t << ", ", _do(_u...); }
#else
#define fastIO() ios_base::sync_with_stdio(0), cin.tie(0)
#define debug(...) void()
#endif

template <typename T, typename U> bool chmin(T &lhs, U rhs) { return lhs > rhs ? lhs = rhs, 1 : 0; }
template <typename T, typename U> bool chmax(T &lhs, U rhs) { return lhs < rhs ? lhs = rhs, 1 : 0; }

#endif

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

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: 3632kb

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
Wrong Answer
time: 1ms
memory: 3632kb

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:

47
47
48
48
47
47
46
46
45
45
46
47
46
44
44
44
43
42
41
41
41
41
41
40
42
42
42
41
40
38
39
38
38
39
38
39
39
40
40
40
40
41
40
40
41
40
39
38
38
38
38
39
38
38
38
38
38
37
36
37
38
37
36
35
37
37
38
38
37
37
39
38
38
38
37
38
38
37
38
39
40
40
39
39
39
39
40
41
40
41
42
41
40
41
39
41
41
43
42
42
...

result:

wrong answer 1st numbers differ - expected: '44', found: '47'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #28:

score: 0
Wrong Answer
time: 16ms
memory: 3588kb

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:

660
660
660
661
661
661
661
660
660
660
660
661
662
662
663
663
662
661
662
662
661
660
661
660
660
660
661
661
661
661
662
661
661
660
661
660
659
658
658
659
659
658
659
660
660
660
660
660
660
659
659
659
659
659
659
659
659
660
659
658
658
658
658
657
657
657
658
657
656
657
657
657
656
656
655
...

result:

wrong answer 615th numbers differ - expected: '660', found: '661'

Subtask #4:

score: 0
Wrong Answer

Test #35:

score: 0
Wrong Answer
time: 16ms
memory: 3588kb

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:

670
670
670
670
670
670
670
670
670
671
671
671
671
672
672
672
671
671
671
672
672
672
671
671
670
670
669
669
668
668
669
669
669
669
669
669
668
668
668
668
667
667
666
666
665
665
665
665
665
665
665
665
665
665
665
665
665
665
665
665
665
666
666
667
667
668
668
668
668
668
668
668
668
667
667
...

result:

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

Subtask #5:

score: 0
Skipped

Dependency #1:

0%