Submission #793695

# Submission time Handle Problem Language Result Execution time Memory
793695 2023-07-26T05:35:49 Z 이동현(#10060) Triangle Collection (CCO23_day2problem3) C++17
10 / 25
4000 ms 8440 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define int long long
using namespace std;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, q;
    cin >> n >> q;
    vector<int> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }

    while(q--){
        int x, y;
        cin >> x >> y;
        --x;

        a[x] += y;

        int ans = 0, h = 0;
        vector<int> b(2 * n), c(2 * n);
        for(int i = 0; i < n; ++i){
            if(a[i] % 2){
                c[i] = 1;
            }
            b[i * 2] = a[i] / 2;
        }
        for(int i = 0; i < 2 * n; ++i){
            ans += b[i];
            h += c[i];
            h -= b[i];
            if(h < 0){
                ans -= (-h - 1) / 3 + 1;
                h %= 3;
                if(h < 0) h += 3;
            }
        }

        cout << ans << '\n';
    }
    
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 16 ms 340 KB Output is correct
7 Correct 14 ms 404 KB Output is correct
8 Correct 7 ms 340 KB Output is correct
9 Correct 18 ms 340 KB Output is correct
10 Correct 14 ms 404 KB Output is correct
11 Correct 16 ms 404 KB Output is correct
12 Correct 13 ms 400 KB Output is correct
13 Correct 13 ms 340 KB Output is correct
14 Correct 6 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 16 ms 340 KB Output is correct
7 Correct 14 ms 404 KB Output is correct
8 Correct 7 ms 340 KB Output is correct
9 Correct 18 ms 340 KB Output is correct
10 Correct 14 ms 404 KB Output is correct
11 Correct 16 ms 404 KB Output is correct
12 Correct 13 ms 400 KB Output is correct
13 Correct 13 ms 340 KB Output is correct
14 Correct 6 ms 340 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 30 ms 416 KB Output is correct
18 Correct 28 ms 404 KB Output is correct
19 Correct 28 ms 416 KB Output is correct
20 Correct 28 ms 416 KB Output is correct
21 Correct 18 ms 404 KB Output is correct
22 Correct 25 ms 420 KB Output is correct
23 Correct 18 ms 408 KB Output is correct
24 Correct 17 ms 416 KB Output is correct
25 Correct 27 ms 408 KB Output is correct
26 Correct 12 ms 400 KB Output is correct
27 Correct 12 ms 340 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 340 KB Output is correct
2 Correct 16 ms 340 KB Output is correct
3 Correct 51 ms 588 KB Output is correct
4 Execution timed out 4091 ms 8440 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 340 KB Output is correct
2 Correct 28 ms 416 KB Output is correct
3 Correct 30 ms 340 KB Output is correct
4 Correct 18 ms 400 KB Output is correct
5 Execution timed out 4051 ms 8312 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 16 ms 340 KB Output is correct
7 Correct 14 ms 404 KB Output is correct
8 Correct 7 ms 340 KB Output is correct
9 Correct 18 ms 340 KB Output is correct
10 Correct 14 ms 404 KB Output is correct
11 Correct 16 ms 404 KB Output is correct
12 Correct 13 ms 400 KB Output is correct
13 Correct 13 ms 340 KB Output is correct
14 Correct 6 ms 340 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 30 ms 416 KB Output is correct
18 Correct 28 ms 404 KB Output is correct
19 Correct 28 ms 416 KB Output is correct
20 Correct 28 ms 416 KB Output is correct
21 Correct 18 ms 404 KB Output is correct
22 Correct 25 ms 420 KB Output is correct
23 Correct 18 ms 408 KB Output is correct
24 Correct 17 ms 416 KB Output is correct
25 Correct 27 ms 408 KB Output is correct
26 Correct 12 ms 400 KB Output is correct
27 Correct 12 ms 340 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 13 ms 340 KB Output is correct
30 Correct 16 ms 340 KB Output is correct
31 Correct 51 ms 588 KB Output is correct
32 Execution timed out 4091 ms 8440 KB Time limit exceeded
33 Halted 0 ms 0 KB -