QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#403640 | #1101. Dispatching | socpite | 100 ✓ | 63ms | 26940kb | C++23 | 920b | 2024-05-02 16:15:17 | 2024-05-02 16:15:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+5;
int n, m;
int B[maxn], C[maxn], L[maxn];
long long ans = 0;
long long sum[maxn];
vector<int> g[maxn];
priority_queue<int> pq[maxn];
void dfs(int x){
pq[x].push(C[x]);
sum[x] = C[x];
for(auto v: g[x]){
dfs(v);
if(pq[v].size() > pq[x].size()){
pq[x].swap(pq[v]);
}
sum[x] += sum[v];
while(!pq[v].empty()){
pq[x].push(pq[v].top());
pq[v].pop();
}
}
while(sum[x] > m){
sum[x] -= pq[x].top();
pq[x].pop();
}
ans = max<long long>(ans, 1LL*pq[x].size()*L[x]);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
for(int i = 1; i <= n; i++){
cin >> B[i] >> C[i] >> L[i];
g[B[i]].push_back(i);
}
dfs(0);
cout << ans;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 30
Accepted
Test #1:
score: 30
Accepted
time: 2ms
memory: 9572kb
input:
10 1000000000 0 1 99007575 1 2 438573466 1 2 1000000000 1 1 353443732 1 2 291838734 1 1 248014694 1 1 147944159 1 2 299181667 1 1 276916145 5 1 155026402
output:
1000000000
result:
ok answer is '1000000000'
Test #2:
score: 0
Accepted
time: 2ms
memory: 10136kb
input:
10 945055475 0 5366694 291855561 1 90389570 179906938 1 374697552 698585353 1 6176408 179386869 1 727971 670724303 1 1530958 402441099 1 7339571 409351640 1 36254496 636788643 4 72938860 1000000000 1 1873379 946221705
output:
2918555610
result:
ok answer is '2918555610'
Test #3:
score: 0
Accepted
time: 0ms
memory: 9380kb
input:
10 1000000000 0 1 200065469 1 1 86267619 2 2 252169035 3 2 442282498 4 1 243844663 5 1 1000000000 6 2 144050751 7 2 158384200 8 1 174667458 9 1 782340303
output:
5000000000
result:
ok answer is '5000000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 9644kb
input:
10 149461880 0 19086773 254109086 1 872978 319976205 2 659016 285454579 3 1044387 215101985 4 1105052 149690214 5 549658 259330154 6 8379103 270606714 7 1217084 347180014 8 286529 1000000000 9 238375 855480256
output:
2879785845
result:
ok answer is '2879785845'
Test #5:
score: 0
Accepted
time: 2ms
memory: 8848kb
input:
10 1000000000 0 1 280411779 1 1 492376696 1 2 265769381 3 2 522023560 4 1 429571633 2 2 631370932 1 1 936743390 5 2 772550684 6 1 664340938 9 1 1000000000
output:
2804117790
result:
ok answer is '2804117790'
Test #6:
score: 0
Accepted
time: 2ms
memory: 10896kb
input:
10 992314729 0 247471573 72238893 1 496728 403783391 1 56679 169951367 1 62461804 383546017 3 5748692 1000000000 3 13294892 101191407 1 7670922 236340829 7 3687984 340008376 6 871973 424696576 9 8546285 243971869
output:
1000000000
result:
ok answer is '1000000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 9496kb
input:
10 1000000000 0 2 119191472 1 1 191898197 1 1 167040153 2 1 458449277 3 1 488571430 5 1 490005524 3 1 176013579 2 1 567598797 8 2 999999999 7 1 718443835
output:
1191914720
result:
ok answer is '1191914720'
Test #8:
score: 0
Accepted
time: 2ms
memory: 9316kb
input:
10 642370756 0 2000999 69581402 1 2242288 236497242 2 40562274 503433968 1 29295199 223094365 4 27350294 386135722 5 116743322 407942097 4 6733483 417947309 2 17931074 1000000000 3 4294057 402743144 2 124931899 302846819
output:
1182486210
result:
ok answer is '1182486210'
Test #9:
score: 0
Accepted
time: 0ms
memory: 10412kb
input:
10 1000000000 0 2 162993968 1 1 283390160 1 2 225721923 2 1 370915202 1 1 219893668 3 1 1000000000 5 2 386516393 5 2 915869674 2 1 387329124 1 2 895863273
output:
1629939680
result:
ok answer is '1629939680'
Test #10:
score: 0
Accepted
time: 0ms
memory: 10472kb
input:
10 370763744 0 744267 91981605 1 4017320 112823498 2 2034586 349731065 1 434048 227023578 2 277595 483312032 3 857061 1000000000 2 5333527 546850487 6 13946625 492486820 8 8072341 542063480 9 9355639 750332484
output:
4000000000
result:
ok answer is '4000000000'
Test #11:
score: 0
Accepted
time: 2ms
memory: 10756kb
input:
100 1000000000 0 2 21970731 1 2 222398317 1 2 74179205 1 2 366800569 4 2 142701324 1 2 394729069 5 1 192544852 1 2 328363234 1 1 506128975 1 1 314621418 1 2 148256480 1 1 329029287 1 2 119329652 1 1 156297911 1 2 167336956 1 2 148648026 1 2 403555792 1 2 300192800 1 2 292834809 1 1 249849421 1 2 315...
output:
2197073100
result:
ok answer is '2197073100'
Test #12:
score: 0
Accepted
time: 2ms
memory: 10616kb
input:
100 627156359 0 466164 39507144 1 2644648 194670076 1 438985 737387156 1 92923 226930065 1 1163019 228612819 1 3229959 262194836 1 12813013 323491896 1 19963029 310811046 1 20016024 426503465 1 2163973 167043338 1 21677491 373443937 1 4661293 658137878 1 3447225 175086764 1 1286302 298126966 1 69079...
output:
3200078664
result:
ok answer is '3200078664'
Test #13:
score: 0
Accepted
time: 2ms
memory: 9720kb
input:
100 1000000000 0 2 60428570 1 1 66827295 2 2 24238861 3 2 32334192 4 2 28224625 5 2 94624940 6 1 77449738 7 1 50072504 8 2 128064792 9 2 54983656 10 1 30104829 10 2 405379841 11 1 129897648 13 2 76542686 14 1 111211868 15 1 38783349 16 2 48425231 17 2 62687740 18 1 58351618 19 1 185804402 20 2 38662...
output:
15719400724
result:
ok answer is '15719400724'
Test #14:
score: 0
Accepted
time: 0ms
memory: 9376kb
input:
100 578318939 0 5917123 49385496 1 73642 30838210 2 345236 19772120 3 1361234 33138006 4 10139793 72436701 5 735377 66290069 6 928511 38162666 7 211991 28589467 8 1639977 46730523 9 514181 41877642 10 13692408 50333956 11 169481 62715369 12 356319 37739429 13 13556 29119131 14 922226 94628561 15 582...
output:
11974219660
result:
ok answer is '11974219660'
Test #15:
score: 0
Accepted
time: 0ms
memory: 9932kb
input:
100 1000000000 0 1 23430721 1 2 41155410 2 1 154924553 2 2 199287253 2 1 759322511 2 1 857571021 2 1 254362696 6 2 222758866 2 2 284553566 9 2 497147783 2 2 119801261 2 2 233978558 2 1 143496080 2 2 229187384 13 1 110307106 2 1 326880148 2 1 215743395 2 2 262011577 2 1 349735861 2 2 543348013 2 1 20...
output:
4419752888
result:
ok answer is '4419752888'
Test #16:
score: 0
Accepted
time: 2ms
memory: 10792kb
input:
100 630848484 0 247658 17408547 1 6205477 34571812 2 3328020 317217034 2 509839 75788562 4 3217643 16823602 1 115888 74851567 6 18532295 209463091 6 8240973 226655261 6 308192 238469613 6 9518868 374670357 6 1038527 483460226 5 605203 35367646 6 30115627 567984503 6 7109805 326307152 6 47163621 1548...
output:
6136951750
result:
ok answer is '6136951750'
Test #17:
score: 0
Accepted
time: 0ms
memory: 8976kb
input:
100 1000000000 0 1 61153166 1 2 113719784 2 1 126178940 1 2 84704700 4 2 63990037 5 2 82315137 3 1 94104156 4 2 67953618 3 2 134366078 6 2 217831760 5 2 161866599 9 2 326554356 11 1 347924435 8 1 59512164 12 2 717356288 6 2 245004266 13 2 376764166 16 1 234975521 10 2 220247525 13 2 407350025 9 2 21...
output:
6115316600
result:
ok answer is '6115316600'
Test #18:
score: 0
Accepted
time: 0ms
memory: 10484kb
input:
100 407636072 0 67732 54528930 1 2021009 86259093 2 532225 75204851 3 7672116 55824152 2 60067 35321439 5 3271885 168012906 4 1744645 179778519 6 200478808 129053288 6 572316 82954639 7 15667139 196631726 9 5299901 276850328 3 1519827 80282398 9 9450035 191431694 4 3050902 361041033 11 132565 191500...
output:
4362314400
result:
ok answer is '4362314400'
Test #19:
score: 0
Accepted
time: 0ms
memory: 9700kb
input:
100 1000000000 0 1 78946076 1 1 178201433 1 2 305193695 3 2 244974740 4 1 266716042 1 2 23378364 1 2 101299598 5 2 266565381 1 2 186234311 9 2 357425108 1 1 205646104 6 1 477249986 8 2 56651834 1 1 112275001 14 2 86180894 11 2 376302134 9 1 87144914 16 1 274961599 17 2 174356033 6 2 177998643 20 1 5...
output:
7894607600
result:
ok answer is '7894607600'
Test #20:
score: 0
Accepted
time: 0ms
memory: 9208kb
input:
100 872316903 0 233970 44229910 1 12892849 87606228 1 51239273 284778432 3 553859 500643173 4 29576733 488625589 1 1450560 115319168 2 161188482 76490812 1 1501983 178628450 1 318879 78557816 8 118859315 298835912 2 29823296 89740365 11 949763 188825255 1 1879806 513131840 2 73339257 104741350 11 13...
output:
3767067804
result:
ok answer is '3767067804'
Test #21:
score: 0
Accepted
time: 3ms
memory: 9244kb
input:
3000 1000000000 0 1 4069630 1 1 73108926 1 2 172743214 1 2 147512131 1 2 133073083 1 1 258347258 1 2 112449690 1 2 188798106 1 1 389065148 1 1 316624828 1 2 98089119 1 1 109629641 1 1 665982137 1 1 132735714 1 2 150518024 1 2 209463789 1 2 226752990 1 1 97564443 1 2 233513718 1 2 235816210 1 2 14781...
output:
12208890000
result:
ok answer is '12208890000'
Test #22:
score: 0
Accepted
time: 3ms
memory: 7176kb
input:
3000 249317273 0 46667 14687857 1 5272676 245994938 1 36279 97314566 1 69173951 117305676 1 893517 203614345 1 808883 285145026 1 161644 75898340 1 386781 201491985 1 841263 680448144 1 2633926 428399351 1 624250 248280374 1 1493324 163928103 1 3490213 103150241 1 1313415 154880109 1 529880 20209052...
output:
12910626303
result:
ok answer is '12910626303'
Test #23:
score: 0
Accepted
time: 3ms
memory: 11296kb
input:
3000 1000000000 0 1 2842710 1 1 8191203 2 1 10476640 3 2 2514314 4 2 1991629 5 2 5664983 6 2 2473494 7 2 2074785 8 2 3343859 9 2 930149 10 2 8405017 11 2 10462097 12 1 6581752 13 2 6252959 13 1 251337684 14 1 5151542 16 2 3963954 17 1 4784129 18 1 3032947 19 1 3804119 20 1 6008879 21 1 3741057 22 1 ...
output:
51266111120
result:
ok answer is '51266111120'
Test #24:
score: 0
Accepted
time: 3ms
memory: 9372kb
input:
3000 545553877 0 1112 6623376 1 55084 2983142 2 26477 2238036 3 198454 3651580 4 307254 4108675 5 20208 4605826 6 212595 1430920 7 11665 1960487 8 9955 8585947 9 3981 2220996 10 1484 2545891 11 24787 9015326 12 7340 4870543 13 1834440 7323977 14 6639 4972471 15 447661 3513072 16 7095 6668487 17 704 ...
output:
63153045378
result:
ok answer is '63153045378'
Test #25:
score: 0
Accepted
time: 3ms
memory: 10696kb
input:
3000 1000000000 0 1 2551098 1 2 4658134 1 1 9714530 3 1 111665704 3 1 215620339 3 2 193069292 3 2 163820550 3 1 167558985 3 2 175669972 3 2 164608893 3 2 127464460 3 1 115046089 3 2 151358953 3 1 227510290 3 2 180392801 3 1 206524775 3 1 144230525 3 1 192047237 3 1 117653311 3 2 138473261 3 1 130739...
output:
31822628332
result:
ok answer is '31822628332'
Test #26:
score: 0
Accepted
time: 3ms
memory: 9160kb
input:
3000 627288487 0 5565 4902237 1 193311 6120910 2 884633 236261695 2 181129 206714678 2 2307166 101024910 2 581462 317698669 2 98512549 385801300 2 310483 66023423 2 3180237 168121712 2 27783537 271228147 2 471456 204701565 2 4294288 235773451 2 31791754 101274420 2 3965170 198231742 2 102185274 1681...
output:
24651134280
result:
ok answer is '24651134280'
Test #27:
score: 0
Accepted
time: 3ms
memory: 9900kb
input:
3000 1000000000 0 1 1630704 1 1 1987962 2 2 5589119 3 1 7223970 4 1 32448774 3 1 5188599 6 1 15621780 4 2 17389129 8 2 15014374 7 2 13153103 9 1 36794153 10 2 17730347 7 2 28184637 10 2 48615555 11 1 18325037 2 1 9277594 6 2 49752398 12 2 33656990 16 1 7068153 14 2 66890883 13 1 31734992 21 1 945233...
output:
13888769780
result:
ok answer is '13888769780'
Test #28:
score: 0
Accepted
time: 4ms
memory: 10752kb
input:
3000 122350483 0 5104 6655606 1 25846 5650899 2 891 27854633 3 45821 6472808 1 342 8933028 4 36546 3178660 5 17151748 82440372 3 627 9920306 6 18499 23584735 4 32051 14065194 10 6336849 13379929 9 172401 13384048 10 115640 13028706 1 829456 55998841 12 536721 28567664 5 4516 3509829 16 255641 925955...
output:
10919016136
result:
ok answer is '10919016136'
Test #29:
score: 0
Accepted
time: 0ms
memory: 10272kb
input:
3000 1000000000 0 2 2232598 1 1 81685454 1 2 3595234 3 1 43985678 2 1 80957227 4 1 281507976 1 1 583943027 1 1 25682946 1 1 19041297 4 1 39629412 10 2 37111715 1 2 5366730 8 2 43213800 9 2 7012543 11 2 135203018 3 2 241743548 14 1 36154576 4 1 119486664 11 1 60171589 13 2 96708931 9 1 18095905 17 2 ...
output:
8707360817
result:
ok answer is '8707360817'
Test #30:
score: 0
Accepted
time: 0ms
memory: 9804kb
input:
3000 93224783 0 77920 4177581 1 781837 203726716 1 1778939 11140736 3 420662 151618788 1 580211 22297732 5 71899 78286588 3 148430 48251650 7 48842 125905178 3 3650082 20852809 9 1864044 117002059 10 1298462 124657597 10 321652 141488523 10 3115814 113503541 5 8390792 220724317 5 14267371 68206206 1...
output:
7551674202
result:
ok answer is '7551674202'
Subtask #2:
score: 70
Accepted
Dependency #1:
100%
Accepted
Test #31:
score: 70
Accepted
time: 19ms
memory: 14852kb
input:
100000 1000000000 0 2 321236 1 2 179850797 1 2 250783699 1 2 58417453 1 2 88037727 1 1 101726249 1 1 67519907 1 2 98597027 1 1 95797654 1 2 132235116 1 1 89711712 1 1 197182213 1 2 198952668 1 2 102774195 1 1 89353143 1 2 219953262 1 1 117958437 1 1 119302871 1 2 222411186 1 2 109585574 1 2 20091023...
output:
32123600000
result:
ok answer is '32123600000'
Test #32:
score: 0
Accepted
time: 36ms
memory: 14636kb
input:
100000 683735612 0 176 3239903 1 7051312 109522014 1 76136860 150341229 1 136391824 64274512 1 976579 70365196 1 593178 73800228 1 12850851 41596789 1 22714409 221017686 1 2693030 130142738 1 5453843 71833211 1 428824 68193617 1 9937268 110141468 1 1314825 90632339 1 590947086 150897121 1 4176660 11...
output:
17223324348
result:
ok answer is '17223324348'
Test #33:
score: 0
Accepted
time: 11ms
memory: 26912kb
input:
100000 1000000000 0 1 649767 1 1 96445010 1 2 439168 3 1 302538 4 1 640384 5 1 336666 6 1 550686 7 2 280587 8 1 332408 9 1 799944 10 2 159505 11 1 307129 12 2 800602 13 1 334090 14 1 631843 15 1 424652 16 2 463325 17 2 104469397 17 2 627728 19 2 174543698 19 2 179802 21 1 305557 22 1 199660 22 1 971...
output:
310649499192
result:
ok answer is '310649499192'
Test #34:
score: 0
Accepted
time: 20ms
memory: 26940kb
input:
100000 317705311 0 206 255096 1 119 494287 2 112 858730 3 1706 695289 4 117669 594584 5 70 294882 6 8994 548450 7 31 338467 8 396 320788 9 35 451164 10 44660367 155944054 10 63 660811 12 198 1341265 13 762 663966 14 25 934668 15 502 361799 16 110 231187 17 299 328400 18 71 608722 19 1144 323218 20 4...
output:
315602908920
result:
ok answer is '315602908920'
Test #35:
score: 0
Accepted
time: 29ms
memory: 18092kb
input:
100000 1000000000 0 1 336376 1 2 429262 2 2 345898 3 1 182789191 3 2 292348 5 2 869860 6 1 811900 7 1 294268 6 2 139506084 1 2 365984 10 1 44373998 10 2 44679953 10 1 107726900 10 2 109266394 10 2 23775781 10 2 76782149 10 1 81510630 10 1 46826821 10 1 130872709 10 1 113650552 10 1 84827102 10 2 597...
output:
237426733440
result:
ok answer is '237426733440'
Test #36:
score: 0
Accepted
time: 41ms
memory: 17736kb
input:
100000 523689236 0 919 731907 1 719 1388722 2 702067 109156645 2 565641 70468645 2 109170 20306353 2 740128 11450590 2 1474495 23569173 2 13161749 55169744 2 1471926 96563674 2 7664794 108552860 2 1327679 120215034 2 50690352 73716536 2 261728448 32111913 2 430595 45575593 2 29131149 35340954 2 8984...
output:
69814449632
result:
ok answer is '69814449632'
Test #37:
score: 0
Accepted
time: 51ms
memory: 19652kb
input:
100000 1000000000 0 2 741680 1 2 1508388 1 1 439923 3 1 2729202 2 1 1768356 3 2 171086 5 2 1080690 4 1 519787 7 1 892217 2 2 236923 7 2 1495572 8 1 740429 6 1 2164159 13 1 2753822 12 1 860134 10 1 727134 16 1 1253055 14 2 2061259 5 1 506113 19 1 1274280 11 1 4215756 4 2 1500069 12 2 2210681 6 1 6595...
output:
75493311012
result:
ok answer is '75493311012'
Test #38:
score: 0
Accepted
time: 61ms
memory: 18280kb
input:
100000 436318930 0 1491 938295 1 129 2746241 1 4122 798475 2 328 1832583 3 1643 959816 4 29103 4062398 2 48185 3002251 4 3046 1950037 8 237415 4781523 7 14748 944951 1 7113617 53303997 10 1896 2945073 6 1020 2082544 13 2134342 2417332 5 3396 1393074 9 4845 4227045 12 12891 4864583 16 69642 17417245 ...
output:
15408385650
result:
ok answer is '15408385650'
Test #39:
score: 0
Accepted
time: 56ms
memory: 17680kb
input:
100000 1000000000 0 1 1360440 1 2 896990 1 1 15962331 1 2 96044616 1 2 2883196 1 1 806834 2 2 26859834 7 2 56208473 5 1 15494722 8 1 52807824 5 2 3894205 6 1 661247 2 2 11270358 3 1 28556040 5 1 5979292 9 2 61894214 15 1 10762954 12 2 57261985 15 2 3455138 14 1 26545382 2 1 3088302 14 1 156644391 21...
output:
136044000000
result:
ok answer is '136044000000'
Test #40:
score: 0
Accepted
time: 63ms
memory: 17224kb
input:
100000 180365096 0 2318 1013091 1 180676 9091850 1 218298 10068890 2 2397728 69882120 1 757869 5747700 1 13484 2205084 1 4060097 5911199 6 2712731 20692464 2 92486 27096712 1 12729 13996338 1 56962 128180677 5 2028139 16346920 2 5853540 34832242 5 2332309 53775586 8 100439 26646849 14 3042 27584155 ...
output:
7442506125
result:
ok answer is '7442506125'