QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#133068#6630. Triangle CollectionCyanmond#0 21ms3684kbC++141.3kb2023-08-01 14:33:322024-07-04 01:05:16

Judging History

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

  • [2024-07-04 01:05:16]
  • 评测
  • 测评结果:0
  • 用时:21ms
  • 内存:3684kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-01 14:33:32]
  • 提交

answer

#include <bits/stdc++.h>
// #include "atcoder/modint"

using i64 = long long;
// using Fp = atcoder::modint998244353;

int main() {
    int N, Q;
    std::cin >> N >> Q;
    std::vector<i64> C(2 * N + 1);
    for (int i = 1; i <= N; ++i) {
        std::cin >> C[i];
    }

    std::vector<i64> L(Q), D(Q);
    for (int i = 0; i < Q; ++i) {
        std::cin >> L[i] >> D[i];
    }

    for (int q = 0; q < Q; ++q) {
        C[L[q]] += D[q];

        i64 ans = 0;
        int l = 1;
        auto X = C;
        for (int i = 1; i <= N; ++i) {
            while (true) {
                if (X[i] < 2) break;
                if (X[i] == 2 and l == i) {
                    while (l != 2 * i and X[l] == 0) ++l;
                    if (l != 2 * i) {
                        X[i] -= 2;
                        --X[l];
                        ++ans;
                        break;
                    } else {
                        l = i;
                        break;
                    }
                }
                while (l != 2 * i and X[l] == 0) ++l;
                if (l == 2 * i) break;
                i64 k = i == l ? X[i] / 3 : std::min(X[i] / 2, X[l]);
                X[i] -= 2 * k;
                X[l] -= k;
                ans += k;
            }
        }
        std::cout << ans << std::endl;
    }
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
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
490
482
467
480
495
498
505
502
505
490
474
487
499
487
504

result:

wrong answer 9th numbers differ - expected: '489', found: '490'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Wrong Answer

Test #28:

score: 0
Wrong Answer
time: 21ms
memory: 3596kb

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: 19ms
memory: 3684kb

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%