Task: | Box Stack II |
Sender: | aalto2024d_003 |
Submission time: | 2024-09-25 17:23:01 +0300 |
Language: | C++ (C++17) |
Status: | READY |
Result: | WRONG ANSWER |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.00 s | details |
#2 | ACCEPTED | 0.00 s | details |
#3 | ACCEPTED | 0.00 s | details |
#4 | ACCEPTED | 0.00 s | details |
#5 | ACCEPTED | 0.00 s | details |
#6 | ACCEPTED | 0.00 s | details |
#7 | ACCEPTED | 0.00 s | details |
#8 | ACCEPTED | 0.00 s | details |
#9 | ACCEPTED | 0.00 s | details |
#10 | ACCEPTED | 0.00 s | details |
#11 | ACCEPTED | 0.00 s | details |
#12 | ACCEPTED | 0.00 s | details |
#13 | ACCEPTED | 0.00 s | details |
#14 | ACCEPTED | 0.01 s | details |
#15 | ACCEPTED | 0.00 s | details |
#16 | ACCEPTED | 0.00 s | details |
#17 | ACCEPTED | 0.00 s | details |
#18 | ACCEPTED | 0.00 s | details |
#19 | ACCEPTED | 0.00 s | details |
#20 | ACCEPTED | 0.00 s | details |
#21 | ACCEPTED | 0.01 s | details |
#22 | ACCEPTED | 0.00 s | details |
#23 | ACCEPTED | 0.00 s | details |
#24 | ACCEPTED | 0.00 s | details |
#25 | ACCEPTED | 0.00 s | details |
#26 | ACCEPTED | 0.00 s | details |
#27 | ACCEPTED | 0.00 s | details |
#28 | ACCEPTED | 0.00 s | details |
#29 | ACCEPTED | 0.00 s | details |
#30 | ACCEPTED | 0.00 s | details |
#31 | ACCEPTED | 0.00 s | details |
#32 | WRONG ANSWER | 0.00 s | details |
#33 | WRONG ANSWER | 0.00 s | details |
#34 | WRONG ANSWER | 0.00 s | details |
#35 | WRONG ANSWER | 0.00 s | details |
#36 | WRONG ANSWER | 0.00 s | details |
#37 | WRONG ANSWER | 0.00 s | details |
#38 | WRONG ANSWER | 0.00 s | details |
#39 | WRONG ANSWER | 0.00 s | details |
#40 | WRONG ANSWER | 0.00 s | details |
#41 | WRONG ANSWER | 0.00 s | details |
#42 | WRONG ANSWER | 0.00 s | details |
#43 | WRONG ANSWER | 0.00 s | details |
#44 | WRONG ANSWER | 0.00 s | details |
#45 | WRONG ANSWER | 0.00 s | details |
#46 | WRONG ANSWER | 0.00 s | details |
#47 | WRONG ANSWER | 0.00 s | details |
#48 | WRONG ANSWER | 0.00 s | details |
#49 | WRONG ANSWER | 0.00 s | details |
#50 | WRONG ANSWER | 0.00 s | details |
#51 | WRONG ANSWER | 0.00 s | details |
#52 | WRONG ANSWER | 0.01 s | details |
#53 | WRONG ANSWER | 0.01 s | details |
#54 | WRONG ANSWER | 0.01 s | details |
#55 | WRONG ANSWER | 0.01 s | details |
#56 | WRONG ANSWER | 0.01 s | details |
#57 | WRONG ANSWER | 0.01 s | details |
#58 | WRONG ANSWER | 0.01 s | details |
#59 | WRONG ANSWER | 0.01 s | details |
#60 | WRONG ANSWER | 0.01 s | details |
#61 | WRONG ANSWER | 0.01 s | details |
#62 | TIME LIMIT EXCEEDED | -- | details |
#63 | TIME LIMIT EXCEEDED | -- | details |
#64 | TIME LIMIT EXCEEDED | -- | details |
#65 | TIME LIMIT EXCEEDED | -- | details |
#66 | TIME LIMIT EXCEEDED | -- | details |
#67 | TIME LIMIT EXCEEDED | -- | details |
#68 | TIME LIMIT EXCEEDED | -- | details |
#69 | TIME LIMIT EXCEEDED | -- | details |
#70 | TIME LIMIT EXCEEDED | -- | details |
#71 | TIME LIMIT EXCEEDED | -- | details |
#72 | TIME LIMIT EXCEEDED | -- | details |
#73 | TIME LIMIT EXCEEDED | -- | details |
Code
#include <iostream> #include <vector> #include <algorithm> using namespace std; struct Box { int length, width, height; Box(int w, int l, int h) : length(l), width(w), height(h) {} }; bool compare(Box& box1, Box& box2) { return (box1.length * box1.width) > (box2.length * box2.width); } int maxHeightBoxStacking(vector<Box>& boxes,int n) { vector<int> maxHeight(n, 0); sort(boxes.begin(), boxes.end(), compare); for (int i = 0; i < n; ++i) { maxHeight[i] = boxes[i].height; for (int j = 0; j < i; ++j) { if (boxes[i].width <= boxes[j].width and boxes[i].length <= boxes[j].length) { maxHeight[i] = max(maxHeight[i], maxHeight[j] + boxes[i].height); } } } int maxStackingHeight = 0; for (int i = 0; i < n; ++i) { maxStackingHeight = max(maxStackingHeight, maxHeight[i]); } return maxStackingHeight; } int main() { int n; cin >> n; vector<Box> v(n,{0,0,0}); for(int i = 0; i < n; i++){ int x,y,z; cin >> x >> y >> z; v[i].width = x; v[i].length = y; v[i].height = z; } cout<<maxHeightBoxStacking(v,n)<<endl; return 0; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
1 7 8 3 |
correct output |
---|
3 |
user output |
---|
3 |
Test 2
Verdict: ACCEPTED
input |
---|
2 6 5 4 1 1 1 |
correct output |
---|
5 |
user output |
---|
5 |
Test 3
Verdict: ACCEPTED
input |
---|
2 3 6 7 9 7 10 |
correct output |
---|
17 |
user output |
---|
17 |
Test 4
Verdict: ACCEPTED
input |
---|
2 5 1 3 8 5 9 |
correct output |
---|
12 |
user output |
---|
12 |
Test 5
Verdict: ACCEPTED
input |
---|
3 7 7 4 2 6 9 2 5 2 |
correct output |
---|
15 |
user output |
---|
15 |
Test 6
Verdict: ACCEPTED
input |
---|
3 8 2 9 9 6 8 7 7 3 |
correct output |
---|
17 |
user output |
---|
17 |
Test 7
Verdict: ACCEPTED
input |
---|
3 1 6 6 5 1 9 10 6 10 |
correct output |
---|
19 |
user output |
---|
19 |
Test 8
Verdict: ACCEPTED
input |
---|
4 1 2 1 7 8 3 3 4 8 6 6 3 |
correct output |
---|
15 |
user output |
---|
15 |
Test 9
Verdict: ACCEPTED
input |
---|
4 8 2 9 9 6 8 7 7 3 1 6 4 |
correct output |
---|
17 |
user output |
---|
17 |
Test 10
Verdict: ACCEPTED
input |
---|
4 1 2 3 5 2 10 6 2 5 7 3 6 |
correct output |
---|
24 |
user output |
---|
24 |
Test 11
Verdict: ACCEPTED
input |
---|
4 9 7 7 3 8 3 2 2 10 10 7 4 |
correct output |
---|
21 |
user output |
---|
21 |
Test 12
Verdict: ACCEPTED
input |
---|
5 6 6 8 9 7 9 6 9 5 7 7 4 ... |
correct output |
---|
30 |
user output |
---|
30 |
Test 13
Verdict: ACCEPTED
input |
---|
5 5 10 8 10 1 2 4 10 2 3 1 4 ... |
correct output |
---|
14 |
user output |
---|
14 |
Test 14
Verdict: ACCEPTED
input |
---|
5 5 2 1 10 6 10 5 5 5 4 4 2 ... |
correct output |
---|
17 |
user output |
---|
17 |
Test 15
Verdict: ACCEPTED
input |
---|
5 6 1 8 9 3 2 6 6 9 5 9 1 ... |
correct output |
---|
20 |
user output |
---|
20 |
Test 16
Verdict: ACCEPTED
input |
---|
5 10 10 6 2 10 9 8 7 7 6 3 2 ... |
correct output |
---|
15 |
user output |
---|
15 |
Test 17
Verdict: ACCEPTED
input |
---|
5 3 1 9 9 3 4 10 10 5 1 7 4 ... |
correct output |
---|
20 |
user output |
---|
20 |
Test 18
Verdict: ACCEPTED
input |
---|
5 9 10 4 3 9 1 1 4 2 10 6 1 ... |
correct output |
---|
11 |
user output |
---|
11 |
Test 19
Verdict: ACCEPTED
input |
---|
5 1 3 8 4 5 10 8 5 10 4 6 3 ... |
correct output |
---|
28 |
user output |
---|
28 |
Test 20
Verdict: ACCEPTED
input |
---|
5 9 1 10 3 9 4 6 9 3 5 1 7 ... |
correct output |
---|
17 |
user output |
---|
17 |
Test 21
Verdict: ACCEPTED
input |
---|
5 1 4 6 5 5 1 2 4 2 1 3 9 ... |
correct output |
---|
18 |
user output |
---|
18 |
Test 22
Verdict: ACCEPTED
input |
---|
10 6 6 8 9 7 9 6 9 5 7 7 4 ... |
correct output |
---|
41 |
user output |
---|
41 |
Test 23
Verdict: ACCEPTED
input |
---|
10 5 10 8 10 1 2 4 10 2 3 1 4 ... |
correct output |
---|
35 |
user output |
---|
35 |
Test 24
Verdict: ACCEPTED
input |
---|
10 5 2 1 10 6 10 5 5 5 4 4 2 ... |
correct output |
---|
33 |
user output |
---|
33 |
Test 25
Verdict: ACCEPTED
input |
---|
10 6 1 8 9 3 2 6 6 9 5 9 1 ... |
correct output |
---|
21 |
user output |
---|
21 |
Test 26
Verdict: ACCEPTED
input |
---|
10 10 10 6 2 10 9 8 7 7 6 3 2 ... |
correct output |
---|
36 |
user output |
---|
36 |
Test 27
Verdict: ACCEPTED
input |
---|
10 3 1 9 9 3 4 10 10 5 1 7 4 ... |
correct output |
---|
37 |
user output |
---|
37 |
Test 28
Verdict: ACCEPTED
input |
---|
10 9 10 4 3 9 1 1 4 2 10 6 1 ... |
correct output |
---|
25 |
user output |
---|
25 |
Test 29
Verdict: ACCEPTED
input |
---|
10 1 3 8 4 5 10 8 5 10 4 6 3 ... |
correct output |
---|
33 |
user output |
---|
33 |
Test 30
Verdict: ACCEPTED
input |
---|
10 9 1 10 3 9 4 6 9 3 5 1 7 ... |
correct output |
---|
28 |
user output |
---|
28 |
Test 31
Verdict: ACCEPTED
input |
---|
10 1 4 6 5 5 1 2 4 2 1 3 9 ... |
correct output |
---|
29 |
user output |
---|
29 |
Test 32
Verdict: WRONG ANSWER
input |
---|
100 589284012 636562060 767928734 906523441 647212241 921212095 585063857 909729626 454895875 669546421 693523526 412726717 ... |
correct output |
---|
10998205207 |
user output |
---|
2141370525 |
Test 33
Verdict: WRONG ANSWER
input |
---|
100 447773962 773442532 122816 137572579 324627123 157577940 253498609 99147813 425825313 199995380 416515986 371043004 ... |
correct output |
---|
8897447989 |
user output |
---|
2145418014 |
Test 34
Verdict: WRONG ANSWER
input |
---|
100 468145963 198730372 27838076 590195590 467423861 520495379 451366491 344173378 354694313 165814381 219739800 750398099 ... |
correct output |
---|
9141888792 |
user output |
---|
2147085310 |
Test 35
Verdict: WRONG ANSWER
input |
---|
100 591414747 75940263 760367935 901888417 312356591 130275571 548496961 611293382 958794496 469291685 962387379 20130523 ... |
correct output |
---|
10698400685 |
user output |
---|
2147242301 |
Test 36
Verdict: WRONG ANSWER
input |
---|
100 967034924 587586158 185430194 918715995 767527830 653946995 749180621 641621091 232024335 151896000 241061404 6689688 ... |
correct output |
---|
12833486742 |
user output |
---|
2145079961 |
Test 37
Verdict: WRONG ANSWER
input |
---|
100 238363353 59249204 934941692 892631472 221963002 390559518 986350949 524427523 96444602 656854970 425992688 822387303 ... |
correct output |
---|
11001071375 |
user output |
---|
2147250166 |
Test 38
Verdict: WRONG ANSWER
input |
---|
100 958701283 356460601 224848374 881788059 68992860 44771412 397401947 115595477 638932295 106806913 568887059 653343572 ... |
correct output |
---|
8425454448 |
user output |
---|
2144868817 |
Test 39
Verdict: WRONG ANSWER
input |
---|
100 81935404 244103474 837431431 342493822 470738321 776814822 489180570 330726191 578205540 283329158 538074003 93140055 ... |
correct output |
---|
10342518662 |
user output |
---|
2144205286 |
Test 40
Verdict: WRONG ANSWER
input |
---|
100 937837681 11934038 257096283 933290530 405355767 570001955 876668629 249890139 453495728 12239373 657165788 462212374 ... |
correct output |
---|
8144852495 |
user output |
---|
2146715878 |
Test 41
Verdict: WRONG ANSWER
input |
---|
100 11139168 391337048 538883744 535937150 532332526 8099343 143698367 339543270 152590624 14304401 234675590 941909102 ... |
correct output |
---|
9522402349 |
user output |
---|
2145984477 |
Test 42
Verdict: WRONG ANSWER
input |
---|
200 589284012 636562060 767928734 906523441 647212241 921212095 585063857 909729626 454895875 669546421 693523526 412726717 ... |
correct output |
---|
15209742885 |
user output |
---|
2147043527 |
Test 43
Verdict: WRONG ANSWER
input |
---|
200 447773962 773442532 122816 137572579 324627123 157577940 253498609 99147813 425825313 199995380 416515986 371043004 ... |
correct output |
---|
13615506574 |
user output |
---|
2147446774 |
Test 44
Verdict: WRONG ANSWER
input |
---|
200 468145963 198730372 27838076 590195590 467423861 520495379 451366491 344173378 354694313 165814381 219739800 750398099 ... |
correct output |
---|
12798974974 |
user output |
---|
2147095258 |
Test 45
Verdict: WRONG ANSWER
input |
---|
200 591414747 75940263 760367935 901888417 312356591 130275571 548496961 611293382 958794496 469291685 962387379 20130523 ... |
correct output |
---|
15137965961 |
user output |
---|
2147069030 |
Test 46
Verdict: WRONG ANSWER
input |
---|
200 967034924 587586158 185430194 918715995 767527830 653946995 749180621 641621091 232024335 151896000 241061404 6689688 ... |
correct output |
---|
17343709538 |
user output |
---|
2147338105 |
Test 47
Verdict: WRONG ANSWER
input |
---|
200 238363353 59249204 934941692 892631472 221963002 390559518 986350949 524427523 96444602 656854970 425992688 822387303 ... |
correct output |
---|
16484729704 |
user output |
---|
2147461814 |
Test 48
Verdict: WRONG ANSWER
input |
---|
200 958701283 356460601 224848374 881788059 68992860 44771412 397401947 115595477 638932295 106806913 568887059 653343572 ... |
correct output |
---|
13668103642 |
user output |
---|
2147010734 |
Test 49
Verdict: WRONG ANSWER
input |
---|
200 81935404 244103474 837431431 342493822 470738321 776814822 489180570 330726191 578205540 283329158 538074003 93140055 ... |
correct output |
---|
12761842389 |
user output |
---|
2147030970 |
Test 50
Verdict: WRONG ANSWER
input |
---|
200 937837681 11934038 257096283 933290530 405355767 570001955 876668629 249890139 453495728 12239373 657165788 462212374 ... |
correct output |
---|
13061107314 |
user output |
---|
2147410568 |
Test 51
Verdict: WRONG ANSWER
input |
---|
200 11139168 391337048 538883744 535937150 532332526 8099343 143698367 339543270 152590624 14304401 234675590 941909102 ... |
correct output |
---|
14114713109 |
user output |
---|
2147120239 |
Test 52
Verdict: WRONG ANSWER
input |
---|
1000 589284012 636562060 767928734 906523441 647212241 921212095 585063857 909729626 454895875 669546421 693523526 412726717 ... |
correct output |
---|
33891762384 |
user output |
---|
2147483363 |
Test 53
Verdict: WRONG ANSWER
input |
---|
1000 447773962 773442532 122816 137572579 324627123 157577940 253498609 99147813 425825313 199995380 416515986 371043004 ... |
correct output |
---|
33355847789 |
user output |
---|
2147468613 |
Test 54
Verdict: WRONG ANSWER
input |
---|
1000 468145963 198730372 27838076 590195590 467423861 520495379 451366491 344173378 354694313 165814381 219739800 750398099 ... |
correct output |
---|
33709682513 |
user output |
---|
2147471614 |
Test 55
Verdict: WRONG ANSWER
input |
---|
1000 591414747 75940263 760367935 901888417 312356591 130275571 548496961 611293382 958794496 469291685 962387379 20130523 ... |
correct output |
---|
34006550890 |
user output |
---|
2147451022 |
Test 56
Verdict: WRONG ANSWER
input |
---|
1000 967034924 587586158 185430194 918715995 767527830 653946995 749180621 641621091 232024335 151896000 241061404 6689688 ... |
correct output |
---|
34976444698 |
user output |
---|
2147482742 |
Test 57
Verdict: WRONG ANSWER
input |
---|
1000 238363353 59249204 934941692 892631472 221963002 390559518 986350949 524427523 96444602 656854970 425992688 822387303 ... |
correct output |
---|
34699884028 |
user output |
---|
2147482715 |
Test 58
Verdict: WRONG ANSWER
input |
---|
1000 958701283 356460601 224848374 881788059 68992860 44771412 397401947 115595477 638932295 106806913 568887059 653343572 ... |
correct output |
---|
34046313943 |
user output |
---|
2147483384 |
Test 59
Verdict: WRONG ANSWER
input |
---|
1000 81935404 244103474 837431431 342493822 470738321 776814822 489180570 330726191 578205540 283329158 538074003 93140055 ... |
correct output |
---|
33580356050 |
user output |
---|
2147478854 |
Test 60
Verdict: WRONG ANSWER
input |
---|
1000 937837681 11934038 257096283 933290530 405355767 570001955 876668629 249890139 453495728 12239373 657165788 462212374 ... |
correct output |
---|
35744107623 |
user output |
---|
2147480355 |
Test 61
Verdict: WRONG ANSWER
input |
---|
1000 11139168 391337048 538883744 535937150 532332526 8099343 143698367 339543270 152590624 14304401 234675590 941909102 ... |
correct output |
---|
35345712189 |
user output |
---|
2147459960 |
Test 62
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 589284012 636562060 767928734 906523441 647212241 921212095 585063857 909729626 454895875 669546421 693523526 412726717 ... |
correct output |
---|
526570534463 |
user output |
---|
(empty) |
Test 63
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 447773962 773442532 122816 137572579 324627123 157577940 253498609 99147813 425825313 199995380 416515986 371043004 ... |
correct output |
---|
527468957174 |
user output |
---|
(empty) |
Test 64
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 468145963 198730372 27838076 590195590 467423861 520495379 451366491 344173378 354694313 165814381 219739800 750398099 ... |
correct output |
---|
530364449483 |
user output |
---|
(empty) |
Test 65
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 591414747 75940263 760367935 901888417 312356591 130275571 548496961 611293382 958794496 469291685 962387379 20130523 ... |
correct output |
---|
531529346089 |
user output |
---|
(empty) |
Test 66
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 967034924 587586158 185430194 918715995 767527830 653946995 749180621 641621091 232024335 151896000 241061404 6689688 ... |
correct output |
---|
532748830637 |
user output |
---|
(empty) |
Test 67
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 238363353 59249204 934941692 892631472 221963002 390559518 986350949 524427523 96444602 656854970 425992688 822387303 ... |
correct output |
---|
525080370284 |
user output |
---|
(empty) |
Test 68
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 958701283 356460601 224848374 881788059 68992860 44771412 397401947 115595477 638932295 106806913 568887059 653343572 ... |
correct output |
---|
529566966249 |
user output |
---|
(empty) |
Test 69
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 81935404 244103474 837431431 342493822 470738321 776814822 489180570 330726191 578205540 283329158 538074003 93140055 ... |
correct output |
---|
521546866708 |
user output |
---|
(empty) |
Test 70
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 937837681 11934038 257096283 933290530 405355767 570001955 876668629 249890139 453495728 12239373 657165788 462212374 ... |
correct output |
---|
531573800077 |
user output |
---|
(empty) |
Test 71
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 11139168 391337048 538883744 535937150 532332526 8099343 143698367 339543270 152590624 14304401 234675590 941909102 ... |
correct output |
---|
529286403784 |
user output |
---|
(empty) |
Test 72
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 1000000000 1000000000 10000000... |
correct output |
---|
200000000000000 |
user output |
---|
(empty) |
Test 73
Verdict: TIME LIMIT EXCEEDED
input |
---|
200000 1000000000 1 1 1000000000 2 2 1000000000 3 3 1000000000 4 4 ... |
correct output |
---|
20000100000 |
user output |
---|
(empty) |