QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#133070 | #6630. Triangle Collection | Cyanmond# | 0 | 18ms | 3616kb | C++14 | 1.4kb | 2023-08-01 14:35:02 | 2024-07-04 01:05:17 |
Judging History
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) {
++l;
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;
}
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 5
Accepted
time: 0ms
memory: 3460kb
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: 3592kb
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: 0ms
memory: 3616kb
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:
44 44 45 45 43 43 43 43 42 42 43 43 42 40 40 40 40 38 38 37 38 37 37 36 38 38 38 37 36 34 36 35 35 36 35 36 36 37 36 37 37 38 38 38 39 38 37 36 36 35 36 36 36 36 35 35 35 35 33 35 35 34 34 33 34 35 36 36 35 35 37 36 36 36 35 35 35 35 35 36 37 37 37 36 37 36 38 38 38 39 39 38 38 38 37 39 39 41 40 40 ...
result:
wrong answer 768th numbers differ - expected: '34', found: '33'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #28:
score: 0
Wrong Answer
time: 12ms
memory: 3604kb
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: 3556kb
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%