QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#117677 | #6630. Triangle Collection | somethingnew# | 10 | 158ms | 13164kb | C++23 | 2.7kb | 2023-07-01 23:00:32 | 2024-05-31 18:46:59 |
Judging History
answer
// ↘ ⬇ ⬇ ⬇ ⬇ ⬇ ↙
// ➡ @roadfromroi ⬅
// ↗ ⬆ ⬆ ⬆ ⬆ ⬆ ↖
#include <iostream>
#include "vector"
#include "algorithm"
#include "numeric"
#include "climits"
#include "iomanip"
#include "bitset"
#include "cmath"
#include "map"
#include "deque"
#include "array"
#include "set"
#include "queue"
#define all(x) x.begin(), x.end()
using namespace std;
#define int long long
struct segtree {
int sz;
vector<int> tree, addk;
segtree(int n) {
sz = 1;
while (sz < n)
sz *= 2;
tree.assign(sz * 2, {});
addk.assign(sz * 2, {});
}
int getv(int v) {
return tree[v] + addk[v];
}
void push(int v) {
addk[v * 2] += addk[v];
addk[v * 2 + 1] += addk[v];
addk[v] = 0;
}
void pull(int v) {
tree[v] = min(getv(v * 2), getv(v * 2 + 1));
}
void add2(int l, int r, int v, int ll, int rr, int x) {
if (ll >= r or rr <= l) {
return;
}
//cerr << l << ' ' << r << v << '\n';
if (ll <= l and r <= rr) {
//cerr << v << ' ' << x << '\n';
addk[v] += x;
return;
}
push(v);
int m = l + r >> 1;
add2(l, m, v * 2, ll, rr, x);
add2(m, r, v * 2 + 1, ll, rr, x);
pull(v);
}
void add(int l, int r, int x) {
return add2(0, sz, 1, l, r+1, x);
}
int get() {
return getv(1);
}
};
void solve() {
int n, q;
cin >> n >> q;
vector<int> a(n), ac;
int sm = 0;
int twdd = 0, ondd = 0;
segtree sg(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
sm += a[i];
twdd += a[i] / 2;
sg.add(0, min(n-1, i * 2), a[i] / 2);
if (a[i] % 2) {
ondd++;
sg.add(0, i, -1);
}
}
for (int i = 0; i < q; ++i) {
int x, c;
cin >> x >> c;
x--;
twdd -= a[x] / 2;
sg.add(0, min(n-1, x * 2), -a[x] / 2);
if (a[x] % 2) {
ondd--;
sg.add(0, x, 1);
}
a[x] += c;
twdd += a[x] / 2;
sm += c;
sg.add(0, min(n-1, x * 2), a[x] / 2);
if (a[x] % 2) {
ondd++;
sg.add(0, x, -1);
}
int rs = sg.get();
int lft = -rs;
int tw2 = twdd - (ondd - lft);
//cout << sm << ' ' << tw2 << ' ' << lft << ' ' << tw2 << '\n';
cout << (sm - lft - (tw2 * 2 % 3)) / 3 << '\n';
}
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int t = 1;
while (t--) {
solve();
}
}
/*
4 3
3 1 4 1
3 -3
1 6
2 1
*/
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3548kb
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:
736 721 711 714 726 729 744 751 734 723 701 719 742 747 758 753 758 735 711 731 749 731 756
result:
wrong answer 1st numbers differ - expected: '491', found: '736'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 5
Accepted
Test #28:
score: 5
Accepted
time: 1ms
memory: 3896kb
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: 1ms
memory: 3932kb
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: 0
Accepted
time: 32ms
memory: 3784kb
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 3 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 5 4 5 4 4 3 3 2 2 2 2 3 3 3 3 2 3 2 2 2 2 2 2 2 3 3 3 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:
ok 200000 numbers
Test #31:
score: 0
Accepted
time: 141ms
memory: 12976kb
input:
200000 200000 2 0 1 2 2 0 2 0 1 1 1 2 0 1 1 0 1 2 2 1 1 0 0 1 0 1 0 1 0 2 1 1 2 0 2 2 2 2 2 0 0 1 1 0 1 1 0 1 0 1 0 0 0 0 1 1 0 0 2 1 2 1 0 1 1 2 0 2 2 0 0 0 1 2 1 2 0 0 0 0 2 2 2 0 2 1 1 1 0 0 0 2 1 1 0 1 0 1 1 2 2 1 1 1 0 2 2 2 2 0 2 1 1 0 0 1 2 0 2 0 2 1 0 2 0 0 1 1 0 1 0 2 0 1 2 0 2 0 1 2 0 2 1 ...
output:
66738 66738 66738 66738 66738 66739 66739 66739 66740 66739 66739 66739 66738 66739 66740 66739 66738 66739 66738 66738 66738 66739 66739 66739 66738 66739 66739 66738 66738 66737 66736 66736 66736 66737 66736 66735 66736 66735 66735 66736 66736 66736 66736 66735 66734 66733 66733 66733 66732 66732 ...
result:
ok 200000 numbers
Test #32:
score: 0
Accepted
time: 143ms
memory: 12936kb
input:
200000 200000 2 1 1 1 1 2 0 0 1 2 1 0 0 2 2 1 0 0 1 1 0 1 2 0 1 0 2 0 1 2 2 2 2 0 0 1 2 2 1 2 1 2 1 2 0 0 0 0 2 0 2 2 0 2 2 1 2 2 1 1 2 0 0 0 0 1 0 0 2 1 1 2 2 1 1 0 1 0 0 2 2 0 0 2 1 2 1 1 2 1 0 1 2 1 2 1 1 2 1 1 1 1 2 2 2 1 1 2 0 1 0 2 0 2 2 2 2 1 0 1 1 0 0 0 2 2 2 2 2 0 1 0 0 2 1 0 2 2 2 2 2 2 2 ...
output:
66650 66650 66650 66650 66650 66650 66650 66650 66651 66650 66649 66649 66649 66648 66648 66648 66648 66648 66648 66648 66647 66646 66647 66647 66648 66648 66648 66648 66649 66649 66649 66649 66649 66649 66648 66648 66648 66649 66649 66648 66648 66648 66648 66648 66648 66647 66647 66647 66648 66647 ...
result:
ok 200000 numbers
Test #33:
score: 0
Accepted
time: 141ms
memory: 12964kb
input:
200000 200000 0 1 2 1 1 1 1 0 2 2 2 1 0 2 2 1 0 1 0 1 1 2 0 0 0 2 0 0 2 0 2 0 0 1 0 2 0 1 0 2 1 0 2 2 1 0 0 1 2 0 1 0 1 2 0 0 2 0 2 1 2 2 2 1 1 2 1 0 2 1 0 0 1 2 1 1 0 1 0 0 2 0 0 0 2 1 0 1 0 2 0 1 1 0 2 0 0 0 1 2 2 0 2 0 0 0 2 1 1 1 2 1 2 2 2 1 0 1 1 2 0 2 2 2 1 1 0 0 1 1 2 0 2 1 1 0 2 2 1 0 2 2 1 ...
output:
66621 66621 66621 66621 66621 66621 66621 66621 66622 66622 66622 66622 66621 66621 66621 66621 66621 66621 66621 66621 66621 66621 66621 66621 66621 66621 66621 66621 66621 66621 66621 66621 66621 66622 66622 66623 66623 66622 66622 66623 66623 66623 66622 66622 66622 66622 66622 66622 66622 66622 ...
result:
ok 200000 numbers
Test #34:
score: 0
Accepted
time: 128ms
memory: 13164kb
input:
200000 200000 2 0 0 2 2 0 2 0 2 0 0 0 2 2 0 0 1 0 0 2 1 2 1 2 0 0 2 0 2 0 0 0 0 1 2 0 2 0 1 2 0 2 0 0 0 0 0 1 0 1 0 0 1 0 0 1 0 1 2 2 0 1 1 0 0 0 1 1 2 0 2 0 1 0 2 2 0 0 2 1 2 0 2 0 1 0 2 2 0 0 2 1 0 0 2 1 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 2 0 2 1 0 0 0 0 0 2 1 1 0 1 0 0 2 2 0 2 0 0 2 0 1 0 0 2 0 0 1 1 ...
output:
49939 49939 49939 49938 49938 49939 49939 49939 49939 49939 49939 49939 49940 49940 49940 49940 49940 49940 49941 49940 49940 49940 49941 49940 49941 49941 49941 49941 49941 49941 49942 49941 49942 49942 49942 49942 49943 49943 49943 49943 49943 49943 49943 49943 49943 49944 49945 49945 49945 49945 ...
result:
ok 200000 numbers
Subtask #4:
score: 5
Accepted
Test #35:
score: 5
Accepted
time: 1ms
memory: 3864kb
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: 2ms
memory: 3640kb
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: 2ms
memory: 3636kb
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: 1ms
memory: 3896kb
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: 0
Accepted
time: 154ms
memory: 12956kb
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:
332845 332845 332846 332845 332845 332845 332844 332844 332844 332845 332844 332845 332844 332844 332844 332843 332843 332843 332842 332842 332842 332842 332842 332843 332843 332843 332844 332843 332843 332843 332844 332843 332843 332843 332842 332843 332842 332842 332842 332842 332842 332841 332842...
result:
ok 200000 numbers
Test #40:
score: 0
Accepted
time: 150ms
memory: 12972kb
input:
200000 200000 85713646 336686856 538585247 278110438 233218655 716436104 837912968 251689084 911446322 701433421 627692917 334396123 413292301 8832435 188412011 689794769 286917079 209754313 519445483 105763643 27705054 168552468 752722351 829700685 747331109 706042730 418755558 614136831 2655911 80...
output:
33341754832470 33341754832470 33341754832471 33341754832470 33341754832471 33341754832470 33341754832470 33341754832470 33341754832470 33341754832470 33341754832470 33341754832470 33341754832471 33341754832470 33341754832471 33341754832470 33341754832471 33341754832471 33341754832471 33341754832472 ...
result:
ok 200000 numbers
Test #41:
score: 0
Accepted
time: 147ms
memory: 13108kb
input:
200000 200000 635910513 530707612 43308926 653927427 953772413 886338816 149455282 24772774 715587632 555119024 702589377 349422399 13059257 305480192 768707679 77455076 588537505 275449414 881106189 997605463 699449988 579049544 439144233 339940611 677203754 952180230 954696649 608213997 944927273 ...
output:
33346597165806 33346597165806 33346597165806 33346597165805 33346597165805 33346597165805 33346597165804 33346597165804 33346597165804 33346597165803 33346597165803 33346597165803 33346597165802 33346597165802 33346597165802 33346597165801 33346597165801 33346597165801 33346597165800 33346597165800 ...
result:
ok 200000 numbers
Test #42:
score: 0
Accepted
time: 158ms
memory: 12960kb
input:
200000 200000 323842684 404575711 975846485 26692339 484624497 479820673 79145839 690422479 435950749 721344329 55972947 946532807 537527876 632207792 134109985 92150997 282767325 50309244 942832532 291033288 394196176 355961510 210549616 639079458 254823064 129598231 941770957 38138695 661229827 98...
output:
33357361283426 33357361283426 33357361283427 33357361283427 33357361283427 33357361283428 33357361283428 33357361283428 33357361283429 33357361283429 33357361283429 33357361283430 33357361283430 33357361283430 33357361283431 33357361283431 33357361283431 33357361283432 33357361283432 33357361283432 ...
result:
ok 200000 numbers
Test #43:
score: 0
Accepted
time: 156ms
memory: 12968kb
input:
200000 200000 1000000000 1000000000 1000000000 999999999 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 999999999 1000000000 999999999 1000000000 1000000000 999999999 999999999 1000000000 1000000000 999999999 1000000000 999999999 1000000000 1000000000 1000000000 1000000000 1000000...
output:
66666666633339 66666666633339 66666666633339 66666666633338 66666666633338 66666666633338 66666666633339 66666666633339 66666666633339 66666666633339 66666666633339 66666666633339 66666666633339 66666666633339 66666666633339 66666666633339 66666666633339 66666666633339 66666666633339 66666666633338 ...
result:
ok 200000 numbers
Subtask #5:
score: 0
Skipped
Dependency #1:
0%