QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#398198 | #6630. Triangle Collection | SorahISA# | 0 | 63ms | 3828kb | C++20 | 3.0kb | 2024-04-25 07:59:49 | 2024-07-04 03:37:44 |
Judging History
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;
auto L = C;
for (int i = 1, j = 1, k = 1; i <= N; ++i) {
if (L[i] < 2) continue;
while (L[i] >= 2) {
while (j <= min(2*i-1, N) and L[j] != 1) ++j;
while (k <= min(2*i-1, N) and L[k] == (k == i ? 2 : 0)) ++k;
if (k < i) {
int cnt = (k == i ? L[i] / 3 : min(L[i] / 2, L[k]));
L[i] -= 2 * cnt, L[k] -= cnt, ans += cnt;
// debug(i, i, k, cnt);
}
else if (k <= min(2*i-1, N) and L[k] == 1) {
L[i] -= 2, L[k] -= 1, ans += 1;
// debug(i, i, k, 1);
}
else if (j <= min(2*i-1, N)) {
L[i] -= 2, L[j] -= 1, ans += 1;
// debug(i, i, j, 1);
}
else if (k <= min(2*i-1, N)) {
int cnt = (k == i ? L[i] / 3 : min(L[i] / 2, L[k]));
L[i] -= 2 * cnt, L[k] -= cnt, ans += cnt;
// debug(i, i, k, cnt);
}
else {
break;
}
}
}
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: 3660kb
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: 3560kb
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: 2ms
memory: 3568kb
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 139th numbers differ - expected: '40', found: '39'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #28:
score: 5
Accepted
time: 29ms
memory: 3600kb
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:
ok 2000 numbers
Test #29:
score: 0
Accepted
time: 17ms
memory: 3828kb
input:
2000 2000 0 1 1 0 0 0 0 1 1 2 0 2 1 2 0 0 0 0 1 0 0 1 2 0 1 1 0 0 1 2 1 1 2 2 2 1 1 2 0 2 2 0 1 0 1 2 2 0 2 0 0 2 0 1 2 2 0 1 0 1 0 1 0 2 0 2 1 2 1 1 0 1 2 0 1 1 1 2 0 2 1 1 2 1 2 0 1 0 0 0 0 2 2 0 2 2 0 2 2 1 0 1 2 1 0 2 0 1 1 2 2 0 0 0 0 2 0 2 2 1 1 1 2 2 0 1 2 0 2 1 0 1 1 2 2 2 0 0 0 0 1 0 0 2 1 ...
output:
679 679 679 679 679 679 679 678 679 678 678 678 679 678 679 678 678 678 678 678 677 678 677 678 678 678 679 678 678 678 678 678 677 677 677 678 677 678 678 678 678 678 678 678 679 678 679 679 679 680 680 680 680 680 680 679 678 677 676 677 676 676 677 676 675 674 674 674 674 674 674 673 673 672 672 ...
result:
ok 2000 numbers
Test #30:
score: -5
Wrong Answer
time: 39ms
memory: 3604kb
input:
10 200000 1 2 2 2 2 1 0 2 2 2 10 -1 3 0 5 0 10 -1 10 0 3 0 5 0 7 1 9 -2 10 2 2 -2 6 -1 6 0 8 -1 4 -2 2 0 5 -1 8 1 1 1 4 1 1 -2 3 0 4 1 9 0 9 0 6 1 7 -1 4 -2 2 1 6 0 8 0 3 0 5 -1 10 -1 5 2 9 1 1 0 6 -1 2 0 9 1 2 1 4 2 5 -2 7 1 3 0 1 2 9 0 5 1 1 -1 6 2 6 -2 9 -1 8 -2 6 1 2 -2 1 -1 10 -1 2 0 8 2 6 -1 2...
output:
5 5 5 4 4 4 4 5 4 5 4 4 4 3 3 3 2 3 2 3 3 3 3 3 3 3 3 2 3 3 3 3 2 2 3 3 3 3 3 3 3 4 3 4 4 4 4 4 4 5 4 4 3 3 2 2 2 2 3 3 3 3 2 3 2 2 2 2 2 2 2 3 2 2 2 2 2 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 2 2 2 2 2 2 2 2 2 2 1 1 1 0 0 0 0 0 0 0 0 1 1 1 1 2 2 2 2 2 3 3 3 2 2 3 3 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 4 4 4 3 3 4 ...
result:
wrong answer 19th numbers differ - expected: '3', found: '2'
Subtask #4:
score: 0
Time Limit Exceeded
Test #35:
score: 5
Accepted
time: 22ms
memory: 3636kb
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:
666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 666 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 665 666 666 666 666 666 666 666 666 666 666 666 666 666 665 ...
result:
ok 1999 numbers
Test #36:
score: 0
Accepted
time: 38ms
memory: 3696kb
input:
1999 2000 938865181 635701131 720186551 12098533 888342577 819466162 677119886 695501777 87063160 544120940 280740814 953384275 462378756 394423771 769842478 563100233 988726627 938258387 941725041 202877851 608668845 507891555 488072389 600920090 738211573 440041095 584208199 334345340 587249363 60...
output:
334310744804 334310744804 334310744805 334310744805 334310744805 334310744805 334310744805 334310744806 334310744805 334310744805 334310744805 334310744805 334310744805 334310744805 334310744805 334310744805 334310744805 334310744805 334310744805 334310744804 334310744805 334310744804 334310744805 3...
result:
ok 2000 numbers
Test #37:
score: 0
Accepted
time: 44ms
memory: 3656kb
input:
1998 2000 953983734 995770518 938631730 961951570 959332856 972648102 943061680 904445058 924304353 960622114 906426330 931936027 957313612 965894280 965137632 988149861 916855162 928712995 923621242 962852409 971372933 948162818 943268160 970351693 997138667 985041992 953192885 954772005 986919660 ...
output:
632914970666 632914970667 632914970666 632914970666 632914970666 632914970665 632914970666 632914970666 632914970666 632914970667 632914970667 632914970667 632914970666 632914970667 632914970666 632914970667 632914970667 632914970667 632914970668 632914970667 632914970668 632914970667 632914970667 6...
result:
ok 2000 numbers
Test #38:
score: 0
Accepted
time: 63ms
memory: 3652kb
input:
2000 1999 0 5 4 1 3 4 1 3 1 0 0 1 4 0 3 5 5 2 3 0 5 3 3 4 5 3 5 5 0 3 4 5 4 0 2 0 0 4 0 5 5 2 2 3 5 5 4 0 3 2 2 2 0 4 5 4 2 2 5 1 5 5 1 4 5 2 0 4 3 1 5 4 5 1 0 3 0 5 2 4 3 0 4 1 2 5 4 1 4 4 1 0 4 1 0 3 5 5 5 3 4 5 5 1 5 5 5 0 0 2 5 0 3 3 2 4 2 1 3 5 3 4 2 5 2 3 2 3 4 5 1 1 2 3 4 3 3 4 2 0 4 0 0 2 1 ...
output:
1655 1655 1656 1656 1656 1655 1655 1655 1656 1656 1656 1655 1656 1656 1656 1657 1657 1657 1657 1657 1658 1657 1658 1657 1657 1657 1657 1657 1657 1657 1656 1657 1656 1656 1656 1655 1656 1656 1656 1656 1656 1657 1657 1657 1657 1657 1658 1657 1657 1657 1657 1657 1657 1657 1657 1657 1657 1657 1657 1657 ...
result:
ok 1999 numbers
Test #39:
score: -5
Time Limit Exceeded
input:
200000 200000 1 4 9 4 6 9 5 8 4 7 8 5 8 4 5 0 10 1 2 5 5 6 2 1 2 5 7 7 5 9 6 6 1 4 6 6 4 2 10 9 6 0 9 10 1 5 7 4 7 5 9 10 0 2 6 10 4 3 7 2 7 7 10 0 5 1 2 2 0 8 10 6 7 4 4 10 0 7 0 8 8 8 6 5 6 5 1 5 10 5 9 3 9 3 6 6 7 7 9 7 5 7 0 7 1 3 7 9 5 0 0 9 10 3 5 3 2 1 8 4 1 0 8 5 7 6 1 1 4 5 1 6 5 3 6 1 5 5 ...
output:
result:
Subtask #5:
score: 0
Skipped
Dependency #1:
0%