CSES - Aalto Competitive Programming 2024 - wk3 - Mon - Results
Submission details
Task:Wheel of fortune
Sender:aalto2024b_005
Submission time:2024-09-16 17:36:14 +0300
Language:C++ (C++11)
Status:READY
Result:
Test results
testverdicttime
#10.00 sdetails
#2--details
#3--details
#4--details
#5--details
#6--details
#70.00 sdetails
#8--details
#9--details
#10--details
#11--details
#12--details
#130.00 sdetails
#14--details
#15--details
#16--details
#17--details
#18--details
#190.00 sdetails
#20--details
#21--details
#22--details
#23--details
#24--details
#25--details
#26--details
#27--details
#28--details
#29--details
#30--details
#31--details
#32--details
#33--details
#34--details
#35--details
#36--details
#37--details
#380.00 sdetails
#39--details
#40--details
#41--details
#42--details
#43--details
#440.00 sdetails
#45--details
#46--details
#47--details
#48--details
#49--details
#500.00 sdetails
#51--details
#52--details
#53--details
#54--details
#55--details
#560.00 sdetails
#57--details
#58--details
#59--details
#60--details
#61--details
#620.01 sdetails
#63--details
#64--details
#65--details
#66--details
#67--details
#680.00 sdetails
#69--details
#70--details
#71--details
#72--details
#73--details
#74--details
#75--details
#76--details
#77--details
#78--details
#79--details
#80--details
#81--details
#82--details
#83--details
#84--details
#85--details
#86--details
#87--details
#88--details
#89--details
#90--details
#91--details
#92--details
#93--details
#94--details
#95--details
#96--details
#97--details
#98--details
#99--details
#1000.01 sdetails

Compiler report

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

Code

#include<iostream>
#include<cstdio>
#include<algorithm>
typedef long long LL;
using std::max;
const int N=1e5+3, INF = 0x3f3f3f3f;

int a[N], f[N][10];

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", &a[i]);

    f[1][1] = a[1];
    f[1][5] = -a[1];

    f[2][1] = -INF;
    f[2][2] = f[1][1] - a[2];
    f[2][3] = f[1][1];
    f[2][3+1] = f[1][5] + a[2];
    f[2][3+2] = -INF;
    f[2][3+3] = f[1][5];
    f[2][6+1] = f[1][9] + a[2];
    f[2][6+2] = f[1][9] - a[2];
    f[2][6+3] = -INF;

    for(int i=3; i<n; i++)
    {
        for(int j=1; j<=3; j++)
        {
            j = j*3 - 3;
            // choose
            f[i][j+1] = max(f[i-1][j+2], f[i-1][j+3]);
            f[i][j+1] += a[i];
            // unchoose
            f[i][j+2] = max(f[i-1][j+1], f[i-1][j+3]);
            f[i][j+2] -= a[i];
            // ignore
            f[i][j+3] = max(f[i-1][j+1], f[i-1][j+2]);
        }
    }

    f[n][1] = -INF;
    f[n][2] = f[n-1][3] - a[n];
    f[n][3] = f[n-1][2];
    f[n][3+1] = f[n-1][3+3] + a[n];
    f[n][3+2] = -INF;
    f[n][3+3] = f[n-1][3+1];
    f[n][6+1] = f[n-1][6+2] + a[n];
    f[n][6+2] = f[n-1][6+1] - a[n];
    f[n][9] = -INF;

    int ans = -INF;
    for(int i=1; i<=9; i++)
        ans = max(ans, f[n][i]);

// for(int i=1; i<=n; i++)
// {
//     for(int j=1; j<=9; j++)
//         printf("%d ", f[i][j]);
//     putchar('\n');
// }

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

Test details

Test 1

Verdict:

input
3
41702 99720 72033 

correct output
58018

user output
(empty)

Test 2

Verdict:

input
4
41702 99720 72033 93257 

correct output
192977

user output
(empty)

Test 3

Verdict:

input
5
41702 99720 72033 93257 11 

correct output
192966

user output
(empty)

Test 4

Verdict:

input
6
41702 99720 72033 93257 11 128...

correct output
205789

user output
(empty)

Test 5

Verdict:

input
7
41702 99720 72033 93257 11 128...

correct output
223199

user output
(empty)

Test 6

Verdict:

input
10
41702 99720 72033 93257 11 128...

correct output
329303

user output
(empty)

Test 7

Verdict:

input
3
43600 18508 2592 

correct output
41008

user output
(empty)

Test 8

Verdict:

input
4
43600 18508 2592 93155 

correct output
111663

user output
(empty)

Test 9

Verdict:

input
5
43600 18508 2592 93155 54967 

correct output
134163

user output
(empty)

Test 10

Verdict:

input
6
43600 18508 2592 93155 54967 9...

correct output
206437

user output
(empty)

Test 11

Verdict:

input
7
43600 18508 2592 93155 54967 9...

correct output
228937

user output
(empty)

Test 12

Verdict:

input
10
43600 18508 2592 93155 54967 9...

correct output
286966

user output
(empty)

Test 13

Verdict:

input
3
55080 7072 70815 

correct output
63743

user output
(empty)

Test 14

Verdict:

input
4
55080 7072 70815 83996 

correct output
125895

user output
(empty)

Test 15

Verdict:

input
5
55080 7072 70815 83996 29090 

correct output
132004

user output
(empty)

Test 16

Verdict:

input
6
55080 7072 70815 83996 29090 1...

correct output
154985

user output
(empty)

Test 17

Verdict:

input
7
55080 7072 70815 83996 29090 1...

correct output
144137

user output
(empty)

Test 18

Verdict:

input
10
96704 90063 54724 17269 97269 ...

correct output
389952

user output
(empty)

Test 19

Verdict:

input
3
96704 90063 54724 

correct output
41980

user output
(empty)

Test 20

Verdict:

input
4
96704 90063 54724 17269 

correct output
151428

user output
(empty)

Test 21

Verdict:

input
5
96704 90063 54724 17269 97269 

correct output
170063

user output
(empty)

Test 22

Verdict:

input
6
96704 90063 54724 17269 97269 ...

correct output
248697

user output
(empty)

Test 23

Verdict:

input
7
96704 90063 54724 17269 97269 ...

correct output
241545

user output
(empty)

Test 24

Verdict:

input
10
96704 90063 54724 17269 97269 ...

correct output
389952

user output
(empty)

Test 25

Verdict:

input
50
41702 99720 72033 93257 11 128...

correct output
1508857

user output
(empty)

Test 26

Verdict:

input
50
43600 18508 2592 93155 54967 9...

correct output
1261022

user output
(empty)

Test 27

Verdict:

input
50
55080 7072 70815 83996 29090 1...

correct output
1204485

user output
(empty)

Test 28

Verdict:

input
50
96704 90063 54724 17269 97269 ...

correct output
1548881

user output
(empty)

Test 29

Verdict:

input
250
41702 99720 72033 93257 11 128...

correct output
7048856

user output
(empty)

Test 30

Verdict:

input
250
43600 18508 2592 93155 54967 9...

correct output
7355456

user output
(empty)

Test 31

Verdict:

input
250
55080 7072 70815 83996 29090 1...

correct output
6879335

user output
(empty)

Test 32

Verdict:

input
250
96704 90063 54724 17269 97269 ...

correct output
7241700

user output
(empty)

Test 33

Verdict:

input
900
41702 99720 72033 93257 11 128...

correct output
25585084

user output
(empty)

Test 34

Verdict:

input
900
43600 18508 2592 93155 54967 9...

correct output
25559325

user output
(empty)

Test 35

Verdict:

input
900
55080 7072 70815 83996 29090 1...

correct output
25395388

user output
(empty)

Test 36

Verdict:

input
900
96704 90063 54724 17269 97269 ...

correct output
25722421

user output
(empty)

Test 37

Verdict:

input
10000
41702 99720 72033 93257 11 128...

correct output
286456959

user output
(empty)

Test 38

Verdict:

input
3
2 3 3 

correct output
1

user output
(empty)

Test 39

Verdict:

input
4
2 4 3 4 

correct output
8

user output
(empty)

Test 40

Verdict:

input
5
3 5 4 5 1 

correct output
9

user output
(empty)

Test 41

Verdict:

input
6
3 6 5 6 1 1 

correct output
13

user output
(empty)

Test 42

Verdict:

input
7
3 7 6 7 1 1 3 

correct output
16

user output
(empty)

Test 43

Verdict:

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

correct output
35

user output
(empty)

Test 44

Verdict:

input
3
2 1 1 

correct output
1

user output
(empty)

Test 45

Verdict:

input
4
2 1 1 4 

correct output
5

user output
(empty)

Test 46

Verdict:

input
5
3 1 1 5 3 

correct output
7

user output
(empty)

Test 47

Verdict:

input
6
3 2 1 6 4 6 

correct output
14

user output
(empty)

Test 48

Verdict:

input
7
4 2 1 7 4 7 4 

correct output
17

user output
(empty)

Test 49

Verdict:

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

correct output
31

user output
(empty)

Test 50

Verdict:

input
3
2 3 3 

correct output
1

user output
(empty)

Test 51

Verdict:

input
4
2 4 3 4 

correct output
8

user output
(empty)

Test 52

Verdict:

input
5
3 5 4 5 1 

correct output
9

user output
(empty)

Test 53

Verdict:

input
6
3 6 5 6 1 1 

correct output
13

user output
(empty)

Test 54

Verdict:

input
7
3 7 6 7 1 1 3 

correct output
16

user output
(empty)

Test 55

Verdict:

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

correct output
35

user output
(empty)

Test 56

Verdict:

input
3
2 1 1 

correct output
1

user output
(empty)

Test 57

Verdict:

input
4
2 1 1 4 

correct output
5

user output
(empty)

Test 58

Verdict:

input
5
3 1 1 5 3 

correct output
7

user output
(empty)

Test 59

Verdict:

input
6
3 2 1 6 4 6 

correct output
14

user output
(empty)

Test 60

Verdict:

input
7
4 2 1 7 4 7 4 

correct output
17

user output
(empty)

Test 61

Verdict:

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

correct output
31

user output
(empty)

Test 62

Verdict:

input
3
2 1 3 

correct output
2

user output
(empty)

Test 63

Verdict:

input
4
3 1 3 4 

correct output
6

user output
(empty)

Test 64

Verdict:

input
5
3 1 4 5 2 

correct output
7

user output
(empty)

Test 65

Verdict:

input
6
4 1 5 6 2 1 

correct output
11

user output
(empty)

Test 66

Verdict:

input
7
4 1 5 6 3 1 4 

correct output
11

user output
(empty)

Test 67

Verdict:

input
10
10 10 6 2 10 9 8 7 7 6 

correct output
41

user output
(empty)

Test 68

Verdict:

input
3
3 3 2 

correct output
1

user output
(empty)

Test 69

Verdict:

input
4
4 4 3 1 

correct output
7

user output
(empty)

Test 70

Verdict:

input
5
5 5 3 1 5 

correct output
9

user output
(empty)

Test 71

Verdict:

input
6
6 6 4 2 6 6 

correct output
16

user output
(empty)

Test 72

Verdict:

input
7
7 7 4 2 7 6 6 

correct output
18

user output
(empty)

Test 73

Verdict:

input
10
10 10 6 2 10 9 8 7 7 6 

correct output
41

user output
(empty)

Test 74

Verdict:

input
50
21 50 37 47 1 7 16 50 8 12 5 2...

correct output
764

user output
(empty)

Test 75

Verdict:

input
50
22 10 2 47 28 48 22 25 22 17 1...

correct output
641

user output
(empty)

Test 76

Verdict:

input
50
28 4 36 42 15 7 26 29 45 22 45...

correct output
610

user output
(empty)

Test 77

Verdict:

input
50
49 46 28 9 49 43 36 31 35 30 1...

correct output
783

user output
(empty)

Test 78

Verdict:

input
250
105 250 181 234 1 33 76 250 37...

correct output
17676

user output
(empty)

Test 79

Verdict:

input
250
109 47 7 233 138 237 109 122 1...

correct output
18449

user output
(empty)

Test 80

Verdict:

input
250
138 18 178 210 73 31 128 143 2...

correct output
17250

user output
(empty)

Test 81

Verdict:

input
250
242 226 137 44 244 214 179 153...

correct output
18157

user output
(empty)

Test 82

Verdict:

input
900
376 898 649 840 1 116 273 900 ...

correct output
230450

user output
(empty)

Test 83

Verdict:

input
900
393 167 24 839 495 853 392 437...

correct output
230221

user output
(empty)

Test 84

Verdict:

input
900
496 64 638 756 262 110 460 513...

correct output
228745

user output
(empty)

Test 85

Verdict:

input
900
871 811 493 156 876 771 644 54...

correct output
231686

user output
(empty)

Test 86

Verdict:

input
10000
4171 9972 7204 9326 2 1282 302...

correct output
28647603

user output
(empty)

Test 87

Verdict:

input
100000
41703 99721 72034 93258 12 128...

correct output
2838931183

user output
(empty)

Test 88

Verdict:

input
100000
43601 18509 2593 93156 54968 9...

correct output
2842573127

user output
(empty)

Test 89

Verdict:

input
100000
55081 7073 70816 83997 29091 1...

correct output
2839271262

user output
(empty)

Test 90

Verdict:

input
4
100000 100000 100000 100000 

correct output
200000

user output
(empty)

Test 91

Verdict:

input
5
100000 100000 100000 100000 10...

correct output
100000

user output
(empty)

Test 92

Verdict:

input
6
100000 100000 100000 100000 10...

correct output
300000

user output
(empty)

Test 93

Verdict:

input
7
100000 100000 100000 100000 10...

correct output
200000

user output
(empty)

Test 94

Verdict:

input
10
100000 100000 100000 100000 10...

correct output
500000

user output
(empty)

Test 95

Verdict:

input
50
100000 100000 100000 100000 10...

correct output
2500000

user output
(empty)

Test 96

Verdict:

input
250
100000 100000 100000 100000 10...

correct output
12500000

user output
(empty)

Test 97

Verdict:

input
900
100000 100000 100000 100000 10...

correct output
45000000

user output
(empty)

Test 98

Verdict:

input
10000
100000 100000 100000 100000 10...

correct output
500000000

user output
(empty)

Test 99

Verdict:

input
100000
100000 100000 100000 100000 10...

correct output
5000000000

user output
(empty)

Test 100

Verdict:

input
3
100000 100000 100000 

correct output
0

user output
(empty)