QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#788792 | #6610. Forged in the Barrens | Arghariza | WA | 1760ms | 44932kb | C++14 | 2.9kb | 2024-11-27 18:19:06 | 2024-11-27 18:19:16 |
Judging History
answer
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define R(i, x, y) for (int i = (x); i >= (y); i--)
#define FIO(FILE) freopen(FILE".in", "r", stdin), freopen(FILE".out", "w", stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<ll> vi;
bool Mbe;
const int N = 2e5 + 5;
const ll inf = 1e14;
int n;
int a[N];
struct Mink {
vector<ll> s;
Mink () { }
Mink (int n) { s.resize(n, -inf); }
void emplace_back(ll x) {
s.eb(x);
}
int size() {
return (int)s.size();
}
ll& operator [](const int &r) {
return s[r];
}
vi::iterator begin() {
return s.begin();
}
vi::iterator end() {
return s.end();
}
Mink shr() {
Mink res(1);
F (i, 0, (int)s.size() - 2) {
res.eb(s[i]);
}
return res;
}
friend Mink operator + (Mink L, Mink R) {
if (!L.size()) {
return R;
}
if (!R.size()) {
return L;
}
int sl = L.size(), sr = R.size();
Mink res = Mink(sl + sr - 1);
res[0] = L[0] + R[0];
R (i, sl - 1, 1) {
L[i] -= L[i - 1];
}
R (i, sr - 1, 1) {
R[i] -= R[i - 1];
}
merge(L.begin() + 1, L.end(), R.begin() + 1, R.end(), res.begin() + 1, greater<int> ());
F (i, 1, sl + sr - 2) {
res[i] += res[i - 1];
}
return res;
}
friend Mink max(Mink L, Mink R) {
int sl = L.size(), sr = R.size();
Mink res(max(sl, sr));
F (i, 0, max(sl, sr) - 1) {
if (i < sl) {
res[i] = max(res[i], L[i]);
}
if (i < sr) {
res[i] = max(res[i], R[i]);
}
}
return res;
}
};
struct Info {
Mink s[3][3];
Info () { }
Info (int w) {
F (i, 0, 2) {
F (j, 0, 2) {
s[i][j] = Mink(2);
}
}
s[0][0][1] = 0;
s[0][1][0] = s[1][0][0] = w;
s[0][2][0] = s[2][0][0] = -w;
}
Mink* operator [](const int &r) {
return s[r];
}
friend Info operator + (Info L, Info R) {
Info res;
F (i, 0, 2) {
F (j, 0, 2) {
res[i][j] = max(res[i][j], L[i][j]);
res[i][j] = max(res[i][j], R[i][j]);
res[i][j] = max(res[i][j], L[i][0] + R[0][j]);
res[i][j] = max(res[i][j], (L[i][1] + R[2][j]).shr());
res[i][j] = max(res[i][j], (L[i][2] + R[1][j]).shr());
}
}
return res;
}
};
Info conq(int l, int r) {
if (l == r) {
return Info(a[l]);
}
int mid = (l + r) >> 1;
return conq(l, mid) + conq(mid + 1, r);
}
void solve() {
cin >> n;
F (i, 1, n) {
cin >> a[i];
}
Mink res = conq(1, n)[0][0];
F (i, 1, n) {
cout << res[i] << '\n';
}
}
bool Med;
int main() {
// FIO("");
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cerr << (&Mbe - &Med) / 1048576.0 << " MB\n";
int T = 1;
// cin >> T;
while (T--) solve();
cerr << (int)(1e3 * clock() / CLOCKS_PER_SEC) << " ms\n";
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3924kb
input:
5 1 2 3 4 5
output:
4 3 2 1 0
result:
ok 5 number(s): "4 3 2 1 0"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
5 1 2 1 2 1
output:
1 2 2 1 0
result:
ok 5 number(s): "1 2 2 1 0"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
6 1 1 4 5 1 4
output:
4 7 7 7 4 0
result:
ok 6 numbers
Test #4:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
6 1 9 1 9 8 1
output:
8 16 23 16 8 0
result:
ok 6 numbers
Test #5:
score: 0
Accepted
time: 0ms
memory: 3884kb
input:
12 1 1 4 5 1 4 1 9 1 9 8 1
output:
8 16 23 27 30 30 30 27 23 16 8 0
result:
ok 12 numbers
Test #6:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
1 882082994
output:
0
result:
ok 1 number(s): "0"
Test #7:
score: 0
Accepted
time: 1522ms
memory: 44792kb
input:
200000 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 200000 numbers
Test #8:
score: 0
Accepted
time: 1640ms
memory: 44748kb
input:
200000 77 70 57 38 68 21 59 7 69 17 9 24 41 68 30 48 34 26 73 39 17 63 76 66 86 4 54 74 39 95 70 4 90 52 69 91 23 60 60 92 3 90 12 80 24 14 61 12 88 41 21 51 64 71 58 62 23 75 100 1 81 1 10 55 51 75 19 10 92 38 16 37 13 65 18 63 1 86 46 97 9 73 90 40 12 47 38 60 83 39 43 54 88 41 41 13 72 76 87 29 8...
output:
99 198 297 396 495 594 693 792 891 990 1089 1188 1287 1386 1485 1584 1683 1782 1881 1980 2079 2178 2277 2376 2475 2574 2673 2772 2871 2970 3069 3168 3267 3366 3465 3564 3663 3762 3861 3960 4059 4158 4257 4356 4455 4554 4653 4752 4851 4950 5049 5148 5247 5346 5445 5544 5643 5742 5841 5940 6039 6138 6...
result:
ok 200000 numbers
Test #9:
score: 0
Accepted
time: 1741ms
memory: 44924kb
input:
200000 6725 7976 5118 7553 190 9162 9839 7494 5930 284 1231 8391 7929 17 5437 6591 9521 318 6383 6725 5208 3790 9775 1925 8398 9279 1280 4765 9977 7481 171 4382 5391 9775 1626 2 8826 926 5952 3661 8011 6642 5892 3403 7182 7672 6008 4969 5205 8126 2506 9120 4371 2487 2838 7356 8616 7067 7030 4188 699...
output:
9999 19998 29997 39996 49995 59994 69993 79992 89991 99990 109989 119988 129987 139985 149983 159981 169979 179977 189975 199973 209971 219969 229967 239965 249962 259959 269956 279953 289950 299947 309943 319939 329935 339931 349927 359923 369918 379913 389908 399903 409898 419893 429888 439883 449...
result:
ok 200000 numbers
Test #10:
score: 0
Accepted
time: 1754ms
memory: 44852kb
input:
200000 318639 561692 87192 536195 560418 918250 125448 871561 884252 611751 493519 912888 61288 819607 498024 74183 888380 205404 641422 258352 623307 282697 692839 220948 232775 831317 424718 511099 759479 897259 794171 398905 280048 870687 982929 51820 309619 193594 834309 692513 443939 702518 757...
output:
999988 1999963 2999926 3999887 4999838 5999787 6999722 7999630 8999515 9999399 10999272 11999131 12998977 13998814 14998639 15998438 16998235 17998024 18997804 19997581 20997357 21997131 22996898 23996659 24996399 25996138 26995859 27995578 28995265 29994926 30994542 31994154 32993722 33993286 34992...
result:
ok 200000 numbers
Test #11:
score: 0
Accepted
time: 1753ms
memory: 44932kb
input:
200000 16174360 16400333 10147420 64255282 34012379 22322316 46803028 15266540 52356248 8256878 41708831 38897524 41997200 43746883 70179269 79493418 51197032 89109521 81587260 16910019 14088072 49440864 48119339 56399861 79397652 10970877 51897127 4851783 71102477 82689816 2471351 66112504 12993722...
output:
99999607 199997298 299994758 399990856 499985864 599975606 699964620 799953428 899939515 999924880 1099909567 1199891101 1299872307 1399851671 1499830854 1599809827 1699786945 1799763312 1899738466 1999713593 2099688097 2199657019 2299625867 2399593541 2499561134 2599528639 2699495781 2799461409 289...
result:
ok 200000 numbers
Test #12:
score: 0
Accepted
time: 1638ms
memory: 44796kb
input:
200000 51 72 70 68 24 29 46 63 87 71 84 89 64 60 46 94 33 98 59 45 48 90 96 60 100 95 61 85 84 64 90 82 44 63 84 45 58 56 17 32 41 65 80 48 74 56 81 11 97 57 50 75 37 97 79 96 43 78 39 58 52 97 66 83 87 46 80 27 99 92 52 69 51 65 58 84 90 45 95 96 24 37 10 54 83 83 79 99 97 95 78 100 92 79 79 98 98 ...
output:
99 198 297 396 495 594 693 792 891 990 1089 1188 1287 1386 1485 1584 1683 1782 1880 1978 2076 2174 2272 2370 2468 2566 2664 2762 2860 2958 3056 3154 3252 3350 3448 3546 3644 3742 3840 3938 4036 4134 4232 4330 4428 4526 4624 4722 4820 4918 5016 5114 5212 5310 5408 5506 5604 5702 5800 5898 5996 6094 6...
result:
ok 200000 numbers
Test #13:
score: 0
Accepted
time: 1707ms
memory: 44932kb
input:
200000 7481 9822 9953 6800 6503 8504 3673 7621 7881 8972 9163 8455 9697 4423 6093 8068 2593 6372 8531 5914 8917 3524 8075 9758 6135 8850 9004 6448 7435 9631 4591 7542 8864 4686 8073 6564 8363 8272 2688 7401 6056 9235 8306 7157 5854 9042 8335 7214 8350 9742 9596 9232 9328 3956 9184 6723 9067 2867 399...
output:
9964 19741 29485 39215 48929 58642 68351 78059 87764 97463 107080 116687 126293 135894 145493 155081 164664 174237 183810 193381 202912 212442 221967 231475 240974 250465 259948 269423 278896 288363 297820 307270 316718 326162 335591 345009 354426 363841 373254 382659 392063 401464 410862 420257 429...
result:
ok 200000 numbers
Test #14:
score: 0
Accepted
time: 1735ms
memory: 44832kb
input:
200000 895762 930905 931854 970053 721855 865844 742357 946077 552830 928266 574679 751638 651121 975674 802114 910419 957714 667760 638229 777516 981443 937136 841918 997639 840350 719747 520025 884589 747440 688809 699145 999696 768534 612411 977797 798373 826004 594559 746390 733103 939580 686498...
output:
970523 1925319 2875884 3811810 4739998 5665473 6587079 7501709 8414753 9327027 10233977 11138055 12041472 12944076 13846538 14745954 15645225 16543907 17440704 18336914 19230449 20123944 21016114 21908265 22798621 23687792 24575103 25462057 26345838 27229138 28111642 28992534 29873248 30753729 31634...
result:
ok 200000 numbers
Test #15:
score: 0
Accepted
time: 1739ms
memory: 44748kb
input:
200000 52914829 87222943 70551264 95271385 93757239 57238849 89644992 73298743 97000598 97048822 90295808 95416171 87685217 91276807 94299449 73670225 98836370 91298947 97512861 83009278 55725008 89966190 99253141 86231681 97361777 67522052 73636395 91516756 42252481 94505759 60166421 95506798 72203...
output:
91418339 179698955 267779262 353992145 439893814 525725431 611333557 696665971 781578181 866423398 950900979 1035200615 1119432961 1203641141 1287843574 1371737475 1455616833 1539291442 1622820716 1706222225 1789445769 1872638907 1955825230 2038941003 2121743234 2204540569 2287217510 2369811255 2452...
result:
ok 200000 numbers
Test #16:
score: 0
Accepted
time: 1633ms
memory: 44772kb
input:
200000 78 48 49 74 52 19 39 30 70 86 73 63 22 28 100 72 51 82 86 89 87 99 71 46 89 75 93 80 60 51 25 98 66 53 21 99 76 42 75 48 79 92 54 39 79 60 73 86 14 51 77 34 80 87 44 11 48 50 76 22 93 91 15 79 15 35 46 31 49 88 64 45 53 30 88 83 42 100 23 34 62 46 94 25 68 23 94 84 18 36 64 18 75 69 56 18 61 ...
output:
90 180 270 360 450 540 630 720 810 900 990 1080 1170 1260 1350 1440 1530 1620 1710 1800 1890 1980 2070 2160 2250 2340 2430 2520 2610 2700 2790 2880 2970 3060 3150 3240 3330 3420 3510 3600 3690 3780 3870 3960 4050 4140 4230 4320 4410 4500 4590 4680 4770 4860 4950 5040 5130 5220 5310 5400 5490 5580 56...
result:
ok 200000 numbers
Test #17:
score: 0
Accepted
time: 1672ms
memory: 44736kb
input:
200000 197 998 673 479 155 625 928 923 799 645 450 944 757 614 428 307 985 976 388 614 361 936 686 731 154 739 498 919 375 977 817 969 249 100 117 243 967 470 430 703 190 886 465 250 351 578 951 643 861 741 640 348 606 763 171 399 987 353 693 678 244 148 888 477 939 122 221 721 468 753 143 449 437 4...
output:
900 1800 2700 3600 4500 5400 6300 7200 8100 9000 9900 10800 11700 12600 13500 14400 15300 16200 17100 18000 18900 19800 20700 21600 22500 23400 24300 25200 26100 27000 27900 28800 29700 30600 31500 32400 33300 34200 35100 36000 36900 37800 38700 39600 40500 41400 42300 43200 44100 45000 45900 46800 ...
result:
ok 200000 numbers
Test #18:
score: 0
Accepted
time: 1739ms
memory: 44804kb
input:
200000 1379 1935 8780 7921 2750 6534 2475 6553 1831 6135 7278 5304 1265 9356 1025 9159 6728 5246 6721 4844 3567 6169 4363 5110 5484 7787 4795 5984 8476 1334 2882 1005 8652 6255 2389 4736 4256 8465 8190 1191 2184 7649 4664 4945 8593 1231 3268 6940 8631 6203 6085 2654 2621 7320 8489 8622 7090 3628 563...
output:
9000 18000 27000 36000 45000 54000 63000 72000 81000 90000 99000 108000 117000 126000 134999 143998 152997 161996 170995 179994 188993 197992 206991 215989 224987 233985 242983 251981 260979 269977 278975 287973 296971 305968 314965 323962 332959 341956 350953 359949 368945 377941 386937 395933 4049...
result:
ok 200000 numbers
Test #19:
score: 0
Accepted
time: 1734ms
memory: 44796kb
input:
200000 86235 24238 97287 12647 90404 80231 57423 73646 21153 41914 24847 33645 79622 46796 85063 61257 66034 61052 81428 11836 32398 58693 70963 70263 70539 96895 21591 84157 88219 29988 40552 88335 76541 70175 57264 50512 78040 20418 19595 34491 78711 83075 10365 87010 51236 46157 44140 15812 46557...
output:
90000 179999 269998 359995 449991 539987 629983 719979 809974 899967 989958 1079949 1169939 1259928 1349916 1439903 1529889 1619874 1709857 1799839 1889820 1979801 2069781 2159759 2249736 2339712 2429686 2519659 2609632 2699603 2789573 2879542 2969511 3059478 3149444 3239408 3329370 3419331 3509291 ...
result:
ok 200000 numbers
Test #20:
score: 0
Accepted
time: 1739ms
memory: 44812kb
input:
200000 647838 608939 410302 970465 263854 824671 324675 588236 612636 213093 992140 169045 614526 282441 310340 334182 306038 464855 898864 150509 653446 126228 508689 730448 742903 244538 153999 258007 315900 957756 629284 583327 421489 429857 359608 424999 990963 499406 741402 902139 655047 777099...
output:
899988 1799965 2699939 3599897 4499848 5399795 6299739 7199666 8099591 8999515 9899438 10799336 11699201 12599061 13498916 14398761 15298601 16198430 17098247 17998061 18897863 19797663 20697451 21597220 22496985 23396720 24296449 25196164 26095875 26995575 27895274 28794943 29694590 30594229 314938...
result:
ok 200000 numbers
Test #21:
score: 0
Accepted
time: 1735ms
memory: 44776kb
input:
200000 4433639 4475409 7888954 6351460 9198208 4437964 1024160 7501046 5622341 8635120 2739776 7260095 9274523 7221285 1712903 9537388 6769069 8762821 8018189 8689868 8931287 9348071 6534122 8425192 3452566 3990803 9597380 3265745 5138951 8311690 7648679 9760112 6752198 4981150 7714803 7295762 24441...
output:
8999980 17999876 26999755 35999582 44999283 53998981 62998490 71997875 80997226 89996377 98995485 107994550 116993416 125992275 134990880 143989359 152987813 161986057 170984210 179982322 188980316 197978255 206975984 215973484 224970975 233968285 242965409 251962391 260959345 269956014 278952531 28...
result:
ok 200000 numbers
Test #22:
score: 0
Accepted
time: 1760ms
memory: 44736kb
input:
200000 24715976 18968483 34057394 28460334 44225411 93642892 15036563 13682371 48317086 90033233 95573445 74657352 94575042 37925026 11125047 54353028 49941949 81589171 84975282 30075130 63768744 51385474 95300707 19266949 38637102 98374333 91825272 10382843 19101410 25119562 21796722 95694261 98729...
output:
89997214 179994014 269988972 359981922 449974559 539966249 629957818 719948857 809939282 899929529 989915915 1079902250 1169888094 1259873319 1349857506 1439841236 1529823746 1619803627 1709782947 1799760683 1889737420 1979712536 2069686220 2159659114 2249630420 2339600297 2429570039 2519539117 2609...
result:
ok 200000 numbers
Test #23:
score: -100
Wrong Answer
time: 1715ms
memory: 44928kb
input:
200000 519897258 486629396 344981192 964777709 767098093 219611415 895545159 230676068 677203881 380833746 760760376 516989046 247773391 762634751 986787718 790954591 211825104 896645492 132648121 107726768 173610526 533479018 589530110 502890535 104582693 632106727 858383583 341136477 821737947 357...
output:
899999389 1799990153 2699975743 3599947291 4499898791 5399844959 6299784964 7199720198 8099651108 8999581092 9899488061 10799388339 11699274882 12599161134 13499040582 14398907053 15298761764 16198603337 17098430688 17998257105 18898074251 19797878241 20697661273 21597443886 22497218159 23396982079 ...
result:
wrong answer 24969th numbers differ - expected: '19136376621243', found: '19136376619779'