QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#614151 | #7964. 转化 | lym | WA | 140ms | 23796kb | C++20 | 2.1kb | 2024-10-05 15:43:53 | 2024-10-05 15:43:55 |
Judging History
answer
#include<bits/stdc++.h>
using i64 = long long;
#define int i64
void solve() {
int n;
std::cin >> n;
std::vector<std::array<int, 4> > a(n + 1);
std::vector<int> e(n + 1);
for (int i = 1; i <= n; i ++) {
std::cin >> a[i][0];
}
for (int i = 1; i <= n; i ++) {
std::cin >> a[i][1];
}
for (int i = 1; i <= n; i ++) {
std::cin >> a[i][2];
a[i][3] = i;
}
i64 sum = 0, res = 0;
for (int i = 1; i <= n; i ++) {
if (a[i][0] && a[i][1]) {
e[a[i][3]] = 1;
sum += a[i][0] + a[i][2];
res += std::min(a[i][0] + a[i][2], a[i][1]);
}
}
std::sort(a.begin() + 1, a.end(), [&](auto x, auto y) {
return x[1] > y[1];
});
for (int i = 1; i <= n; i ++) {
if (e[a[i][3]] || a[i][1] == 0) continue;
if (! a[i][0]) {
sum += a[i][2];
res --;
res += std::min(a[i][2] + 1ll, a[i][1]);
} else if (! a[i][1]) { // a[i]
sum += a[i][0] + a[i][2];
}
}
std::vector<int> b;
for (int i = 1; i <= n; i ++) {
if (e[a[i][3]] || a[i][1] != 0) continue;
b.push_back(a[i][2]);
}
std::sort(b.begin(), b.end(), [&](auto x, auto y) {
return x > y;
});
for (auto it : b) {
if (res) {
sum += it;
res --;
} else {
break;
}
}
std::vector<int> d(n + 1);
i64 op = 0;
res = 0;
for (int i = 1; i <= n; i ++) {
if (a[i][0] && a[i][1]) {
d[a[i][3]] = std::min(a[i][1], a[i][0] + a[i][2]);
op += d[a[i][3]];
}
}
for (int i = 1; i <= n; i ++) {
if (e[a[i][3]]) continue;
if (! a[i][0]) {
if (! a[i][1]) continue;
op --;
d[a[i][3]] = std::min(a[i][2] + 1ll, a[i][1]) - 1;
op += std::min(a[i][2] + 1ll, a[i][1]);
} else if (! a[i][1]) { // a[i]
d[a[i][3]] = 0;
continue;
}
}
std::sort(a.begin() + 1, a.end(), [&](auto x, auto y) {
return x[3] < y[3];
});
for (int i = 1; i <= n; i ++) {
//if (a[i][0])
std::cout << a[i][0] + a[i][2] + op - d[i] << ' ';
/*else
std::cout << a[i][2] + op - d[i] << ' '*/
}
std::cout << '\n';
std::cout << sum << '\n';
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t = 1;
//std::cin >> t;
while (t --) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 138ms
memory: 19532kb
input:
351493 0 37836791 46095966 46912389 21595941 0 3 86568894 3 0 0 0 0 39910208 0 2 4 86885825 1 67660833 0 24488082 52447896 0 67190942 70457491 11166998 90470470 11095822 0 0 5 47222930 2 49736354 0 0 0 77339472 0 5 3 0 25347727 0 3 2 0 48844622 0 65142757 1 73733079 80634668 46683173 0 31644647 9760...
output:
60073965049724 60073472376204 60073472376204 60073481727701 60073472376204 60073788737330 60073528128564 60073472376204 60073844358663 60073784179153 60073472376204 60073472376204 60073948665985 60073472376204 60073472376204 60073667185445 60073550333929 60073472376204 60073631548329 60073472376204 ...
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 100ms
memory: 23012kb
input:
351493 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 3 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 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 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
389246793 773056414 285033292 35143062 150613 960166465 230310734 742299190 422307527 716629610 559282116 167517603 440667606 980062124 288964464 150613 37777273 995600801 890644898 919111990 697350089 651910449 818599875 248723392 345836780 145972754 169220149 798545767 375398590 724669763 34806631...
result:
ok 2 lines
Test #3:
score: 0
Accepted
time: 103ms
memory: 22768kb
input:
351493 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 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 1 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 1 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 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
599928111 417141936 854896025 376367102 774244714 431347641 604428665 574576714 470717519 508427611 661004235 780213577 84639091 782348432 977630323 52634924 626665121 482558683 636948807 603433753 409075001 417850332 684775391 679542511 719331660 492363039 456376909 467979366 476324957 877501995 64...
result:
ok 2 lines
Test #4:
score: 0
Accepted
time: 110ms
memory: 23272kb
input:
351493 0 0 0 0 0 0 0 0 0 1 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 1 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 1 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...
output:
234262012 949494804 82908292 191866383 357435182 204774625 522310720 616383576 669531277 934418239 418093087 176599775 558496944 589988117 536611693 719041426 393842787 894965977 442976541 747100948 881012457 102085201 428412083 822550482 143067532 981918566 430936426 25974206 579590037 454042457 40...
result:
ok 2 lines
Test #5:
score: 0
Accepted
time: 109ms
memory: 23648kb
input:
351493 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 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 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...
output:
128008403 324553663 567933292 352701143 783282673 190594692 301533599 364177284 279223184 982011115 93673715 984964467 694999373 151789026 608274793 364103610 722660414 902592001 505336386 710937535 144028291 977947521 939107253 81123640 489859775 616594062 747964503 257737750 184925226 573986693 69...
result:
ok 2 lines
Test #6:
score: 0
Accepted
time: 110ms
memory: 23588kb
input:
351493 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 1 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...
output:
135537378 771625312 536097501 20213016 535181834 389664567 646906761 439261845 604414717 122073351 544573434 555440990 473217959 753742657 427447196 328125403 663339101 361706486 617803180 381697 380150870 491441284 648366445 41765814 360790940 64770237 8269659 883453857 164022584 717730739 38863223...
result:
ok 2 lines
Test #7:
score: 0
Accepted
time: 106ms
memory: 23456kb
input:
351493 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 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...
output:
397895996 637995776 229045033 825330009 767600063 813818467 860123184 473916537 39383333 89515696 295009890 10782291 372810895 397106838 65300807 768273191 161781327 558687773 892380213 997363960 385764448 22703610 982241186 895750416 96016857 270822409 184030026 63955892 10774423 640378158 74099131...
result:
ok 2 lines
Test #8:
score: 0
Accepted
time: 96ms
memory: 23796kb
input:
351493 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...
output:
937860890 34071976 153771718 177360430 75823376 355942669 817622492 33321178 780612344 710342440 867761534 819546823 849795236 387301401 347039271 721730011 293246843 210709301 905223131 575724303 974254853 803061206 526936739 665484693 827418578 936873247 622147268 618233327 71709769 20220377 61051...
result:
ok 2 lines
Test #9:
score: 0
Accepted
time: 104ms
memory: 22476kb
input:
351493 0 0 0 0 0 0 0 0 1 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...
output:
435339533 792017085 464874946 290155819 579911507 640903189 342715414 80024579 593597993 923890984 22164621 500092442 167224561 545848585 824255335 357704902 384102972 646689026 931844789 998355973 867635578 679726200 342953628 643482846 263712027 200418610 243247433 592213486 987760060 722168666 93...
result:
ok 2 lines
Test #10:
score: 0
Accepted
time: 100ms
memory: 23504kb
input:
351493 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 1 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...
output:
833039146 386929609 340423205 531466641 871513381 539735531 38851078 625200748 836156601 380070044 502844392 663920285 81812085 967432557 346664249 48454327 694363639 920398413 737128643 210103788 316873705 207959069 968250648 934731855 693334060 101169019 756029280 262208629 321830512 391991139 594...
result:
ok 2 lines
Test #11:
score: 0
Accepted
time: 98ms
memory: 22416kb
input:
351493 1 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...
output:
405088761 101567444 728951605 827202557 592729186 993933762 544207082 573547807 740785481 642283084 508301387 658596714 880081299 428702910 647742423 871485073 922595409 61803352 111880604 980556804 700313131 970944731 12619655 901675021 72919073 456429643 363561947 63108889 918585697 104003852 2815...
result:
ok 2 lines
Test #12:
score: 0
Accepted
time: 140ms
memory: 19684kb
input:
351493 88714965 71401825 0 2 65340397 4 0 25757289 0 0 79287460 33735256 89924335 0 0 0 46887462 53594628 73153573 5 4 8609832 0 0 84289549 47034696 3 2 1 0 0 0 10442427 83297278 0 83254899 81067526 86290766 0 0 76225443 93238820 25579442 1 99813770 0 0 57496765 56462270 0 45359891 4 95456406 4 0 0 ...
output:
60022238291213 60022283200411 60022238291213 60022334747309 60022238291213 60022486742140 60022382662050 60022252019465 60022540104218 60022617440125 60022278693895 60022243103919 60022238291213 60022238291213 60022608660168 60022654651589 60022238291213 60022238291213 60022238291213 60022432128879 ...
result:
ok 2 lines
Test #13:
score: 0
Accepted
time: 110ms
memory: 22448kb
input:
351493 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 1 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 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...
output:
702564817 100823161 976824880 722677204 270342297 390544606 288764811 178799230 128949266 500213679 986185297 203792722 708410305 995195713 913017351 793311928 757650203 842297357 769532267 528585592 587492728 435998502 275323368 605638584 736013380 483281328 708700007 341410096 246645414 929757076 ...
result:
ok 2 lines
Test #14:
score: -100
Wrong Answer
time: 92ms
memory: 20204kb
input:
351493 5 6 6 6 7 8 4 4 4 0 7 1 3 7 1 8 0 2 4 0 8 3 3 1 7 8 6 1 1 7 1 3 0 6 8 8 8 2 3 1 2 4 4 0 0 6 6 0 4 3 0 6 6 3 4 8 7 8 8 2 8 0 0 1 4 3 0 3 5 5 3 1 8 7 2 6 2 4 2 0 6 3 2 3 3 6 6 1 3 6 6 2 0 7 0 3 6 1 3 7 5 8 0 3 1 6 7 3 1 4 2 1 2 3 2 0 6 8 8 8 1 4 5 0 6 0 8 4 5 2 5 6 8 0 8 0 7 5 2 4 7 6 2 5 2 8 0...
output:
1229990 1229992 1229990 1229996 1229996 1229995 1229993 1229996 1229994 1229990 1230004 1229998 1229994 1229998 1229995 1229993 1229990 1229995 1229991 1229992 1229996 1229995 1229991 1229992 1229998 1230005 1229990 1229990 1229990 1230003 1229993 1229994 1229990 1229997 1229991 1230000 1230004 1229...
result:
wrong answer 2nd lines differ - expected: '2813994', found: '2657418'