QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#256097#7750. Revenge on My Bossucup-team173#WA 634ms9216kbC++171.9kb2023-11-18 17:51:232023-11-18 17:51:25

Judging History

你现在查看的是最新测评结果

  • [2023-11-18 17:51:25]
  • 评测
  • 测评结果:WA
  • 用时:634ms
  • 内存:9216kb
  • [2023-11-18 17:51:23]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define Mp make_pair
#define SZ(x) (int((x).size()))

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int t;
void solve(int cas) {
    int n;
    cin >> n;

    vector<array<ll, 5>> ve(n);
    ll a = 0, b = 0;
    for(int i = 0; i < n; i++) {
        cin >> ve[i][0] >> ve[i][1] >> ve[i][2];
        if(ve[i][0] < ve[i][1]) a += ve[i][0];
        else b += ve[i][1];
        ve[i][3] = i;
    }
    
    for(int i = 0; i < n; i++) {
        ve[i][4] = (a + b + max(ve[i][0], ve[i][1])) * ve[i][2];
    }

    vi ans; ll val = LLONG_MAX;
    for(int _ = 0; _ < 100; _++) {
        sort(ve.begin(), ve.end(), [&](auto a, auto b) {
            auto [a1, b1, c1, id1, d1] = a;
            auto [a2, b2, c2, id2, d2] = b;
            ll ij = max(d1 + c1 * max(0ll, b2 - a2), d2 + c2 * max(0ll, a1 - b1));
            ll ji = max(d1 + c1 * max(0ll, a2 - b2), d2 + c2 * max(0ll, b1 - a1));
            return ij < ji;
        });
        vector<ll> prea(n), sufb(n);
        prea[0] = ve[0][0];
        for(int i = 1; i < n; i++) prea[i] = prea[i - 1] + ve[i][0];
        sufb[n - 1] = ve[n - 1][1];
        for(int i = n - 2; i >= 0; i--) sufb[i] = sufb[i + 1] + ve[i][1];
        ll now = 0;
        for(int i = 0; i < n; i++) {
            now = max(now, ve[i][2] * (prea[i] + sufb[i]));
        }
        if(now < val) {
            ans.clear();
            for(auto i : ve) ans.pb(i[3]);
        }
    }
    
    for(auto i : ans) cout << i + 1 << ' ';
    cout << '\n';
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> t;
    for(int i = 0; i < t; i++) solve(i + 1);
    return 0;
}
/*
2
4
1 1 4
5 1 5
1 9 1
9 8 1
9
3 1 4
1 5 9
2 6 5
3 5 8
9 7 9
3 2 3
8 4 6
2 6 8
3 2 7

*/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3464kb

input:

2
4
1 1 4
5 1 5
1 9 1
9 8 1
9
3 1 4
1 5 9
2 6 5
3 5 8
9 7 9
3 2 3
8 4 6
2 6 8
3 2 7

output:

3 1 2 4 
3 8 4 2 5 9 7 1 6 

result:

ok correct

Test #2:

score: 0
Accepted
time: 543ms
memory: 9184kb

input:

1
100000
581297 102863 1
742857 42686 1
676710 233271 1
443055 491162 1
442056 28240 1
769277 331752 1
8608 369730 1
495112 525554 1
787449 938154 1
441186 850694 1
84267 925450 1
740811 32385 1
834021 37680 1
257878 564126 1
90618 914340 1
239641 463103 1
40687 343062 1
587737 458554 1
103684 48666...

output:

70717 6151 48237 28851 35679 19561 94252 73342 13089 34865 69194 82763 50242 22597 3745 24913 97923 53671 77581 47428 82224 93567 61401 50007 4886 54152 28731 91278 99937 6691 26840 6048 46204 66044 60735 44469 20513 45842 18701 46818 27203 9261 50507 8020 72391 54368 86201 18839 64763 61758 40939 3...

result:

ok correct

Test #3:

score: 0
Accepted
time: 527ms
memory: 9216kb

input:

1
99999
30245 831673 1
495617 185056 1
53028 422589 1
503558 778900 1
636981 480008 1
966864 78785 1
644954 303138 1
153080 225499 1
876411 832264 1
758904 549009 1
945000 441995 1
83780 789901 1
883282 832556 1
300776 548075 1
806599 108342 1
354979 831549 1
152110 819163 1
613891 812479 1
856259 6...

output:

42779 26176 16432 93736 36110 21022 69840 33300 88899 48735 97468 24934 58044 16598 54398 41611 25297 90410 54385 14754 38513 7374 40518 45724 3741 95478 36354 5270 92123 87433 5901 57489 42968 40570 60847 61715 65894 68944 27887 3727 38578 14748 15072 79314 41234 42830 79639 35429 60443 63782 12370...

result:

ok correct

Test #4:

score: 0
Accepted
time: 525ms
memory: 9168kb

input:

1
100000
361850 684411 2
188930 167748 2
676274 449963 1
970095 784305 1
412379 854673 1
208323 612179 1
296548 633970 1
560983 633064 2
848966 248363 2
741057 340814 1
393854 435721 2
302707 834494 1
229770 235051 2
875992 747523 2
314215 448795 1
531181 809914 2
786505 95721 1
86557 773136 1
44527...

output:

16321 7131 35939 39108 40409 52183 70501 74664 56736 85313 78033 67062 11374 28893 29910 76382 77675 16590 14329 99654 33902 81051 93812 47118 54934 27805 77685 57504 62353 47016 36321 65709 30222 17782 92966 93722 32969 69339 20699 31143 29231 20833 32593 17020 77014 2193 20753 96742 16406 11108 56...

result:

ok correct

Test #5:

score: 0
Accepted
time: 530ms
memory: 9188kb

input:

1
99999
810798 413222 2
974394 310117 1
987184 606577 2
30598 6635 1
607304 306441 1
438614 583404 1
932894 375890 1
994760 333009 2
937928 950984 2
58774 6426 1
287291 728073 1
421484 592009 1
470520 62631 1
918891 764176 2
997492 642796 1
679223 178361 2
865224 571822 2
112711 192469 1
165146 9387...

output:

38004 71563 34947 26525 22330 44909 47503 52297 78657 28797 29991 22680 7929 68438 15865 70932 27655 90081 30923 61265 20749 31006 35033 64820 20963 86257 21420 27746 3451 43480 36392 44360 16524 76128 8052 60705 72335 52826 82386 88960 8813 60213 12369 84977 96785 82723 23228 1372 34613 67012 54683...

result:

ok correct

Test #6:

score: 0
Accepted
time: 514ms
memory: 9184kb

input:

1
100000
142404 976360 1
924602 517001 3
610429 601247 2
529839 44745 3
606894 456914 2
488586 84093 1
360297 674019 1
435366 740573 3
943187 591275 3
8223 87831 2
703441 689095 1
673115 893499 3
817008 689318 2
237211 187815 1
472404 15953 2
822721 932534 2
275427 591484 3
393890 928933 1
11058 141...

output:

51206 37611 59015 50700 80703 52328 53240 43032 8346 8263 41296 64851 47024 78344 80432 99788 79216 80112 84718 81292 91031 58261 72331 98859 85353 71212 34320 28981 4231 54595 26732 77344 6558 79986 1230 64802 4053 35487 35001 47208 53390 6142 58146 9701 11407 53054 48744 52885 2922 93682 94826 636...

result:

ok correct

Test #7:

score: 0
Accepted
time: 535ms
memory: 9176kb

input:

1
99999
815544 929362 2
644659 659371 3
954043 790565 3
398854 42883 3
577627 875978 2
718877 831126 1
996643 640131 2
869143 249030 3
32149 261192 1
325941 753442 3
372686 238344 2
48789 426822 2
57757 260002 1
280109 237173 3
931489 242658 2
970763 300980 2
578337 100288 1
611532 282858 3
506737 2...

output:

27161 35747 25296 34165 9717 57726 57073 11785 24054 83782 88554 68057 42695 23849 49568 78850 8501 69293 52754 11183 39393 98733 35177 37567 85341 22705 9930 96866 82802 47796 9996 57550 29112 27373 52932 83741 39761 26412 12546 99295 22521 45367 72274 77249 22609 44764 11050 29507 28236 24580 4570...

result:

ok correct

Test #8:

score: 0
Accepted
time: 520ms
memory: 9184kb

input:

1
100000
179854 525204 1
403379 866255 3
544585 817939 4
832686 337889 3
577217 283347 1
960336 331815 3
424045 970964 1
309749 591186 4
37408 677291 2
308093 545247 1
45732 199365 1
267715 728311 2
404245 919393 4
855325 436620 1
406400 774600 3
146965 279345 3
955837 376846 3
860006 276218 2
28724...

output:

24436 23350 14823 6635 16186 28793 85545 28010 65377 49593 9096 36992 62631 55712 98568 36492 47289 43010 3738 84762 70128 48544 57069 75781 59468 17061 39547 97907 7290 48134 29862 84143 19385 42718 49107 41621 94075 30404 65165 61273 78021 98586 89053 17836 39470 53504 98341 37199 90866 20337 9343...

result:

ok correct

Test #9:

score: 0
Accepted
time: 545ms
memory: 9144kb

input:

1
99999
628802 478207 4
156140 784432 3
920902 198745 3
925893 336026 4
772142 702412 2
190627 335745 3
93095 937076 4
710822 356539 2
126370 604104 4
625811 243562 3
714977 524422 2
386493 485827 2
677699 522781 4
898224 453274 1
89677 777113 3
262303 647792 3
291451 852947 2
886160 662847 1
848327...

output:

25476 82833 20708 62196 65199 34417 31863 24519 6410 2660 86721 49138 41559 14233 14538 12861 77995 81983 14766 34516 89431 97096 88505 83091 38565 74389 94338 68659 85344 5885 21302 17145 57922 53773 76261 38160 50466 83035 84330 45236 77809 51690 49927 6715 43442 92483 55111 97458 84347 80388 4440...

result:

ok correct

Test #10:

score: 0
Accepted
time: 513ms
memory: 9184kb

input:

1
100000
993111 41344 2
849452 991316 3
287252 969223 4
392430 565624 3
547540 852885 3
240598 836434 5
520498 11013 2
151428 698695 1
98926 987499 3
607963 259559 2
131127 518148 5
638124 530420 3
991483 116764 5
440736 876913 1
564589 309054 1
438505 593453 5
701654 872609 4
391530 399311 5
628832...

output:

40304 73884 46665 34832 83244 13265 71577 34416 81702 34262 55470 14854 96718 20687 75463 16459 34149 34475 8088 30861 77981 72514 92859 39810 55233 80930 35735 85535 89142 73204 61946 48999 88803 32652 61389 33091 39964 64315 41786 22045 69345 85883 21081 60246 54103 75958 66900 11113 17122 41787 3...

result:

ok correct

Test #11:

score: 0
Accepted
time: 549ms
memory: 9176kb

input:

1
99999
633547 770155 1
634916 133686 5
855058 382733 4
485637 596466 2
742466 271949 3
470889 583467 1
156844 977125 2
585205 464048 5
187887 690121 3
892977 925171 2
57268 34693 4
981093 255232 2
232232 977047 5
516338 893566 4
247866 311567 3
586547 994603 5
4565 348710 5
417684 977428 3
124510 7...

output:

48240 97152 38149 92052 85126 48738 420 86878 1608 77274 25520 16300 85538 61415 87215 9020 23040 6708 82083 15814 66859 99499 16595 23692 38022 28113 27468 68026 15427 8746 33174 14077 72913 80575 26563 66510 41324 17717 35068 39018 73663 45534 19933 82609 30013 16591 13958 58164 4681 66871 61356 1...

result:

ok correct

Test #12:

score: 0
Accepted
time: 541ms
memory: 9148kb

input:

1
100000
997857 590189 5
552421 307866 1
221408 153211 4
952174 826064 4
742055 646614 4
712348 116860 2
808438 307957 5
250004 806205 1
193147 297708 2
875130 941168 5
473418 995714 5
975828 556721 3
578721 379543 1
834658 317206 4
722778 876212 3
730045 972968 6
414768 657972 1
633455 746596 6
970...

output:

58367 96255 27046 51517 62990 14996 43792 8080 70637 88785 56968 29155 30934 51774 59548 29427 90925 70372 58953 41857 33191 96145 17321 23404 87318 1596 46324 13075 9593 11090 26264 56726 77126 83979 64736 94161 65026 25548 5002 62346 36677 33190 44945 17805 87787 14720 15278 41786 55909 91963 1146...

result:

ok correct

Test #13:

score: 0
Accepted
time: 541ms
memory: 9124kb

input:

1
99999
414101 318999 4
305181 450235 4
789213 599425 5
12677 889610 6
936981 98382 2
942639 831190 3
444784 241365 4
683780 538854 3
314812 329 6
192848 447995 3
142664 320771 6
384205 90044 2
595278 174418 6
877557 109667 2
181863 102918 3
910791 341415 2
526191 134073 2
659609 133225 3
690293 561...

output:

35478 18624 78085 84422 64480 8449 51230 4571 89366 63494 34463 41028 36180 21314 30197 81273 40400 69808 42147 3988 98521 2452 13595 43642 69108 39646 93137 95922 39452 1217 10651 80682 35534 34784 49882 14755 73947 23645 38923 95063 30177 52114 49164 98219 208 98408 5373 71603 93716 11385 60484 18...

result:

ok correct

Test #14:

score: 0
Accepted
time: 517ms
memory: 9140kb

input:

1
100000
778411 171737 3
31198 657119 3
155563 369903 1
511917 119207 6
679674 248855 4
992610 588775 5
872187 572198 6
91683 913714 4
254664 416428 3
175000 463992 3
815710 281793 4
603132 358830 2
165958 576913 2
420069 533307 7
656775 410667 2
278481 287076 5
160586 153734 2
164979 126586 2
27930...

output:

10495 78296 86975 66984 43573 26013 68012 28684 21728 84715 73054 55225 80985 71471 19208 75959 3227 49197 78757 51517 90370 45175 30815 33044 22612 38359 10155 50081 38746 20159 29238 80523 64318 24082 8081 80300 49009 47185 51927 50099 81484 31393 93483 48777 27137 18152 11576 10916 63727 96750 55...

result:

ok correct

Test #15:

score: 0
Accepted
time: 546ms
memory: 9184kb

input:

1
99999
451551 900548 5
783958 575297 1
756073 750709 5
605124 150049 5
907304 667919 2
190198 335808 4
508533 538310 7
525460 422171 6
409034 310537 1
268526 129603 1
484955 798337 5
946101 116345 4
215220 404493 1
495671 549960 7
340051 637372 6
169627 688226 2
206600 629835 3
191133 480511 4
3188...

output:

54269 84814 11203 22266 69715 2067 98594 58686 77120 97588 24647 22779 41418 74818 11208 77299 68401 83198 48458 83840 10016 73446 1390 25559 11910 57243 94269 68865 21808 3045 36095 77465 14015 56072 4637 32888 22833 39225 85587 87637 73770 70840 9918 92119 76820 76804 18268 93252 20843 97020 35269...

result:

ok correct

Test #16:

score: 0
Accepted
time: 517ms
memory: 9140kb

input:

1
100000
783156 687878 1
477270 782181 2
122423 521187 1
814765 379647 8
906893 42584 3
464361 836497 8
935935 677655 6
966066 829735 7
348885 726636 6
474870 178304 5
901105 792063 5
940836 193643 7
785900 806988 3
38183 973599 4
814963 945121 3
570021 666591 6
840996 939097 7
406903 216975 2
62090...

output:

72039 60446 79913 606 67084 74974 38540 46212 13925 18473 33329 54770 80078 8805 94531 69295 94929 82414 11017 59740 69274 52094 98394 64031 74594 3026 65376 40859 93220 16215 56539 99398 84080 23209 38748 2719 88190 13990 91697 28371 94299 21350 58000 46528 27 406 68868 13024 13756 32181 12213 6526...

result:

ok correct

Test #17:

score: 0
Accepted
time: 544ms
memory: 9136kb

input:

1
99999
45362 965532 6
708808 306508 2
624384 151389 1
467716 670928 1
39438 96594 5
942210 88149 7
892926 875304 8
241522 637190 1
564772 772170 8
835563 334036 7
104129 627390 5
911109 785971 7
389695 864643 9
475004 239058 3
432237 738985 3
818115 349146 8
665532 910961 8
964582 950889 9
682361 7...

output:

17464 54738 19792 69939 35189 77452 89261 55631 50252 91841 70330 4005 64528 98810 51735 25631 44169 2070 89979 41652 86742 62362 45691 29466 82233 78136 91194 51184 6693 82962 21064 93923 22440 83984 47051 39021 91148 97090 43528 17339 33500 58672 69501 561 7869 9766 74630 46576 40530 51413 7570 62...

result:

ok correct

Test #18:

score: 0
Accepted
time: 535ms
memory: 9148kb

input:

1
100000
545343 214678 2
896330 34297 10
225650 145117 5
3539 141992 10
866014 337066 4
787360 33077 10
990193 565400 7
746446 687990 6
657093 370479 9
221001 777823 3
818490 795673 2
891597 771810 3
322069 291555 3
680477 429062 4
131032 471991 3
498884 709254 9
4962 615960 7
537100 173421 1
166345...

output:

47267 41095 99945 82746 72235 4514 7505 33683 57213 5896 21646 65793 2233 37477 35903 26024 55083 75580 81907 2157 93532 35053 37297 29849 58079 67046 3739 68803 90621 34886 53352 54246 56947 73238 88362 25725 54684 92792 65858 7259 30656 70002 31250 66964 37747 13385 86380 82236 46760 47662 82866 1...

result:

ok correct

Test #19:

score: -100
Wrong Answer
time: 634ms
memory: 9184kb

input:

1
99999
336110 764075 4
762927 765956 4
275286 70789 5
459972 469529 7
870966 316414 7
498229 41636 11
830500 307315 6
854475 488251 5
759873 905341 5
993842 970385 9
217019 809676 12
207189 933113 4
625602 520131 7
736635 340574 11
921162 795091 6
552353 769663 10
406594 84507 8
465432 768495 3
892...

output:

39708 59543 43462 38768 62809 86685 85130 49266 10175 30405 5060 45395 16901 19161 77253 78326 74569 15283 81622 25091 32911 13276 24367 31315 53191 86779 19835 56034 94131 84931 2385 7006 43089 26503 35302 20787 17665 96835 31205 81685 18723 58976 78156 39068 12414 83152 77700 16443 27841 74989 144...

result:

wrong answer Wrong Answer on Case#1