CSES - Aalto Competitive Programming 2024 - wk3 - Wed - Results
Submission details
Task:Box stack I
Sender:aalto2024c_007
Submission time:2024-09-18 17:46:41 +0300
Language:C++ (C++20)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#20.00 sdetails
#3ACCEPTED0.00 sdetails
#4ACCEPTED0.00 sdetails
#5ACCEPTED0.00 sdetails
#6ACCEPTED0.00 sdetails
#7ACCEPTED0.00 sdetails
#8ACCEPTED0.00 sdetails
#9ACCEPTED0.00 sdetails
#10ACCEPTED0.01 sdetails
#11ACCEPTED0.00 sdetails
#12ACCEPTED0.00 sdetails
#130.00 sdetails
#14ACCEPTED0.00 sdetails
#150.00 sdetails
#160.00 sdetails
#17ACCEPTED0.00 sdetails
#180.00 sdetails
#190.00 sdetails
#20ACCEPTED0.00 sdetails
#21ACCEPTED0.00 sdetails
#22ACCEPTED0.00 sdetails
#23ACCEPTED0.00 sdetails
#240.00 sdetails
#250.00 sdetails
#26ACCEPTED0.00 sdetails
#270.00 sdetails
#280.00 sdetails
#29ACCEPTED0.00 sdetails
#300.00 sdetails
#310.00 sdetails
#320.00 sdetails
#330.00 sdetails
#340.00 sdetails
#350.00 sdetails
#360.00 sdetails
#370.00 sdetails
#380.00 sdetails
#390.00 sdetails
#400.00 sdetails
#410.01 sdetails
#420.01 sdetails
#430.00 sdetails
#440.01 sdetails
#450.01 sdetails
#460.00 sdetails
#470.00 sdetails
#480.00 sdetails
#490.00 sdetails
#500.01 sdetails
#510.01 sdetails
#520.01 sdetails
#530.01 sdetails
#540.01 sdetails
#550.01 sdetails
#560.01 sdetails
#570.01 sdetails
#580.01 sdetails
#590.01 sdetails
#600.01 sdetails

Compiler report

input/code.cpp: In function 'void Test()':
input/code.cpp:22:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     freopen("temp\\in.txt", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
input/code.cpp: In function 'int main()':
input/code.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
input/code.cpp:30:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |         scanf("%d%d%d", &a[i].w, &a[i].c, &a[i].h);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Code

#include<iostream>
#include<cstdio>
#include<algorithm>
typedef long long LL;

const int N=2005, INF = 0x3f3f3f3f;

int f[N], w[N], c[N], h[N];
struct Node
{
    int w, c, h;
}a[N];
bool CMP(const Node& A, const Node& B)
{
    if(A.c == B.c)
        return A.w < B.w;
    return A.c > B.c;
}

void Test()
{
    freopen("temp\\in.txt", "r", stdin);
}
int main()
{
    // Test();
    int n;
    scanf("%d", &n);
    for(int i=1; i<=n; i++)
        scanf("%d%d%d", &a[i].w, &a[i].c, &a[i].h);
    for(int i=0; i<=2000; i++)
        f[i] = -INF;
    f[2000] = 0;

    std::sort(a+1, a+n+1, CMP);

    for(int p=1; p<=n; p++)
    {
        // consider p;
        for(int i=0; i<=2000; i++)
        {
            int new_c = std::min(i-a[p].w, a[p].c);
            if(new_c < 0)
                continue;

            f[new_c] = std::max(f[new_c], f[i]+a[p].h);
        }
    }
    int ans = -INF;
    for(int i=2000; i>=0; i--)
        ans = std::max(ans, f[i]);

    printf("%d", ans);
    return 0;
}

Test details

Test 1

Verdict: ACCEPTED

input
1
6 7 10

correct output
10

user output
10

Test 2

Verdict:

input
2
5 2 4
1 2 10

correct output
14

user output
10

Test 3

Verdict: ACCEPTED

input
2
8 2 3
3 8 5

correct output
8

user output
8

Test 4

Verdict: ACCEPTED

input
3
7 3 6
10 8 9
3 6 2

correct output
15

user output
15

Test 5

Verdict: ACCEPTED

input
3
9 6 9
4 4 6
7 2 7

correct output
15

user output
15

Test 6

Verdict: ACCEPTED

input
3
10 7 6
3 2 8
2 1 9

correct output
23

user output
23

Test 7

Verdict: ACCEPTED

input
4
8 4 2
3 4 10
5 10 5
2 6 2

correct output
17

user output
17

Test 8

Verdict: ACCEPTED

input
4
3 6 5
1 1 10
10 9 5
4 8 6

correct output
26

user output
26

Test 9

Verdict: ACCEPTED

input
4
7 3 6
10 5 9
6 10 1
6 7 1

correct output
10

user output
10

Test 10

Verdict: ACCEPTED

input
4
8 1 6
2 7 7
9 6 2
5 2 10

correct output
17

user output
17

Test 11

Verdict: ACCEPTED

input
5
6 6 8
9 7 9
6 9 5
7 7 4
...

correct output
18

user output
18

Test 12

Verdict: ACCEPTED

input
5
5 10 8
10 1 2
4 10 2
3 1 4
...

correct output
18

user output
18

Test 13

Verdict:

input
5
5 2 1
10 6 10
5 5 5
4 4 2
...

correct output
17

user output
15

Test 14

Verdict: ACCEPTED

input
5
6 1 8
9 3 2
6 6 9
5 9 1
...

correct output
17

user output
17

Test 15

Verdict:

input
5
10 10 6
2 10 9
8 7 7
6 3 2
...

correct output
22

user output
16

Test 16

Verdict:

input
5
3 1 9
9 3 4
10 10 5
1 7 4
...

correct output
19

user output
18

Test 17

Verdict: ACCEPTED

input
5
9 10 4
3 9 1
1 4 2
10 6 1
...

correct output
12

user output
12

Test 18

Verdict:

input
5
1 3 8
4 5 10
8 5 10
4 6 3
...

correct output
28

user output
21

Test 19

Verdict:

input
5
9 1 10
3 9 4
6 9 3
5 1 7
...

correct output
16

user output
14

Test 20

Verdict: ACCEPTED

input
5
1 4 6
5 5 1
2 4 2
1 3 9
...

correct output
18

user output
18

Test 21

Verdict: ACCEPTED

input
10
6 6 8
9 7 9
6 9 5
7 7 4
...

correct output
22

user output
22

Test 22

Verdict: ACCEPTED

input
10
5 10 8
10 1 2
4 10 2
3 1 4
...

correct output
29

user output
29

Test 23

Verdict: ACCEPTED

input
10
5 2 1
10 6 10
5 5 5
4 4 2
...

correct output
25

user output
25

Test 24

Verdict:

input
10
6 1 8
9 3 2
6 6 9
5 9 1
...

correct output
19

user output
17

Test 25

Verdict:

input
10
10 10 6
2 10 9
8 7 7
6 3 2
...

correct output
31

user output
25

Test 26

Verdict: ACCEPTED

input
10
3 1 9
9 3 4
10 10 5
1 7 4
...

correct output
28

user output
28

Test 27

Verdict:

input
10
9 10 4
3 9 1
1 4 2
10 6 1
...

correct output
21

user output
20

Test 28

Verdict:

input
10
1 3 8
4 5 10
8 5 10
4 6 3
...

correct output
28

user output
25

Test 29

Verdict: ACCEPTED

input
10
9 1 10
3 9 4
6 9 3
5 1 7
...

correct output
27

user output
27

Test 30

Verdict:

input
10
1 4 6
5 5 1
2 4 2
1 3 9
...

correct output
29

user output
27

Test 31

Verdict:

input
100
1098 1186 1431
1689 1206 1716
1090 1695 848
1248 1292 769
...

correct output
16023

user output
14340

Test 32

Verdict:

input
100
835 1995 1441
1866 1 257
605 1999 294
473 185 794
...

correct output
16049

user output
14608

Test 33

Verdict:

input
100
872 371 52
1864 1100 1896
871 970 841
642 661 309
...

correct output
14165

user output
12499

Test 34

Verdict:

input
100
1102 142 1417
1680 582 243
1022 1139 1786
875 1793 38
...

correct output
12391

user output
10775

Test 35

Verdict:

input
100
1935 1802 1095
346 1946 1712
1430 1219 1396
1196 433 283
...

correct output
19385

user output
16782

Test 36

Verdict:

input
100
444 111 1742
1663 414 728
1838 1959 977
180 1224 794
...

correct output
15364

user output
13655

Test 37

Verdict:

input
100
1786 1895 664
419 1643 129
84 741 216
1971 1191 199
...

correct output
15648

user output
14003

Test 38

Verdict:

input
100
153 455 1560
638 877 1957
1447 912 1956
617 1077 528
...

correct output
12527

user output
10910

Test 39

Verdict:

input
100
1747 23 1938
479 1739 756
1062 1633 466
845 23 1225
...

correct output
12817

user output
11281

Test 40

Verdict:

input
100
21 729 1004
999 992 16
268 633 285
27 438 1755
...

correct output
15927

user output
14305

Test 41

Verdict:

input
200
1098 1186 1431
1689 1206 1716
1090 1695 848
1248 1292 769
...

correct output
20991

user output
19122

Test 42

Verdict:

input
200
835 1995 1441
1866 1 257
605 1999 294
473 185 794
...

correct output
24785

user output
23225

Test 43

Verdict:

input
200
872 371 52
1864 1100 1896
871 970 841
642 661 309
...

correct output
20005

user output
18551

Test 44

Verdict:

input
200
1102 142 1417
1680 582 243
1022 1139 1786
875 1793 38
...

correct output
21655

user output
19710

Test 45

Verdict:

input
200
1935 1802 1095
346 1946 1712
1430 1219 1396
1196 433 283
...

correct output
24716

user output
22690

Test 46

Verdict:

input
200
444 111 1742
1663 414 728
1838 1959 977
180 1224 794
...

correct output
20753

user output
19338

Test 47

Verdict:

input
200
1786 1895 664
419 1643 129
84 741 216
1971 1191 199
...

correct output
25462

user output
23726

Test 48

Verdict:

input
200
153 455 1560
638 877 1957
1447 912 1956
617 1077 528
...

correct output
19588

user output
18406

Test 49

Verdict:

input
200
1747 23 1938
479 1739 756
1062 1633 466
845 23 1225
...

correct output
19995

user output
18349

Test 50

Verdict:

input
200
21 729 1004
999 992 16
268 633 285
27 438 1755
...

correct output
26434

user output
24375

Test 51

Verdict:

input
1000
1098 1186 1431
1689 1206 1716
1090 1695 848
1248 1292 769
...

correct output
51198

user output
49287

Test 52

Verdict:

input
1000
835 1995 1441
1866 1 257
605 1999 294
473 185 794
...

correct output
49723

user output
47889

Test 53

Verdict:

input
1000
872 371 52
1864 1100 1896
871 970 841
642 661 309
...

correct output
47760

user output
45751

Test 54

Verdict:

input
1000
1102 142 1417
1680 582 243
1022 1139 1786
875 1793 38
...

correct output
46095

user output
43998

Test 55

Verdict:

input
1000
1935 1802 1095
346 1946 1712
1430 1219 1396
1196 433 283
...

correct output
55178

user output
52856

Test 56

Verdict:

input
2000
444 111 1742
1663 414 728
1838 1959 977
180 1224 794
...

correct output
76003

user output
73972

Test 57

Verdict:

input
2000
1786 1895 664
419 1643 129
84 741 216
1971 1191 199
...

correct output
69375

user output
67535

Test 58

Verdict:

input
2000
153 455 1560
638 877 1957
1447 912 1956
617 1077 528
...

correct output
68402

user output
66443

Test 59

Verdict:

input
2000
1747 23 1938
479 1739 756
1062 1633 466
845 23 1225
...

correct output
76262

user output
74508

Test 60

Verdict:

input
2000
21 729 1004
999 992 16
268 633 285
27 438 1755
...

correct output
81251

user output
79431