CSES - KILO 2017 2/5 - Results
Submission details
Task:Odd sequence
Sender:Viljamin opetuslapset
Submission time:2017-09-12 18:42:14 +0300
Language:Java
Status:READY
Result:
Test results
testverdicttime
#10.32 sdetails
#20.29 sdetails
#30.23 sdetails
#40.33 sdetails
#50.12 sdetails
#60.12 sdetails
#70.13 sdetails
#80.14 sdetails
#90.10 sdetails
#100.13 sdetails
#110.10 sdetails
#120.14 sdetails
#130.11 sdetails
#140.13 sdetails
#150.10 sdetails
#160.12 sdetails
#170.12 sdetails
#180.11 sdetails
#190.12 sdetails
#200.14 sdetails
#210.12 sdetails
#220.12 sdetails
#230.15 sdetails
#240.12 sdetails
#250.11 sdetails
#260.13 sdetails
#270.15 sdetails
#280.12 sdetails
#290.12 sdetails
#300.13 sdetails
#310.13 sdetails
#320.12 sdetails
#330.12 sdetails
#340.10 sdetails
#350.12 sdetails
#360.12 sdetails
#370.12 sdetails
#380.11 sdetails
#390.12 sdetails
#400.12 sdetails
#410.12 sdetails
#420.12 sdetails
#430.11 sdetails
#440.13 sdetails
#450.14 sdetails
#460.13 sdetails
#470.12 sdetails
#480.12 sdetails
#490.11 sdetails
#500.12 sdetails
#510.10 sdetails

Code



import java.util.ArrayList;
import java.util.PriorityQueue;

/**
 *
 * @author juliuuus
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        IO io = new IO();
        int lukuja = io.nextInt();
        
        long suurin = 0;
        
        long[] summat = new long[lukuja];
        long[] luvut = new long[lukuja];
        
        
        for (int i = 0; i < lukuja; i++) {
            long nykyinen = io.nextInt();
            luvut[i] = nykyinen;
            
            if(i < 2) {
                summat[i] = nykyinen;
            } else {
                long summaB = summat[i - 2] + luvut[i - 1] + nykyinen;
                if(summaB > nykyinen) {
                    summat[i] = summaB;
                } else {
                    summat[i] = nykyinen;
                }
            }
            
            if(suurin < summat[i]) {
                suurin = summat[i];
            }
        }
        
        io.println(suurin);
    }

}

Test details

Test 1

Verdict:

input
1000000
0 99833416 198669330 295520206...

correct output
20008336040

user output
(empty)

Test 2

Verdict:

input
1000000
-84 -60 -41 -100 8 -8 -52 -62 ...

correct output
48760

user output
(empty)

Test 3

Verdict:

input
1000000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

correct output
5300

user output
(empty)

Test 4

Verdict:

input
1000000
13915014 -15160138 25244495 40...

correct output
105192740048

user output
(empty)

Test 5

Verdict:

input
10
1 1 -1 -1 -1 1 0 -1 1 -1

correct output
1

user output
(empty)

Test 6

Verdict:

input
10
0 -1 1 -1 -1 -1 1 1 -1 -1

correct output
1

user output
(empty)

Test 7

Verdict:

input
10
1 0 1 -1 0 1 1 1 -1 0

correct output
3

user output
(empty)

Test 8

Verdict:

input
10
1 0 1 -1 0 1 -1 -1 0 1

correct output
2

user output
(empty)

Test 9

Verdict:

input
10
0 0 0 0 0 -1 1 -1 1 1

correct output
1

user output
(empty)

Test 10

Verdict:

input
10
1 -1 -1 1 1 0 1 0 1 0

correct output
4

user output
(empty)

Test 11

Verdict:

input
10
0 1 -1 -1 -1 1 1 0 0 0

correct output
2

user output
(empty)

Test 12

Verdict:

input
10
1 -1 -1 -1 -1 1 -1 1 0 1

correct output
2

user output
(empty)

Test 13

Verdict:

input
10
-1 0 1 0 -1 1 -1 0 1 -1

correct output
1

user output
(empty)

Test 14

Verdict:

input
10
1 -1 0 1 0 0 -1 0 -1 1

correct output
1

user output
(empty)

Test 15

Verdict:

input
10
1 1 1 0 -1 1 0 1 -1 1

correct output
3

user output
(empty)

Test 16

Verdict:

input
10
-1 1 1 0 -1 -1 0 1 0 1

correct output
2

user output
(empty)

Test 17

Verdict:

input
10
-1 -1 1 0 1 -1 1 1 1 -1

correct output
4

user output
(empty)

Test 18

Verdict:

input
10
-1 -1 -1 0 1 1 0 -1 1 -1

correct output
2

user output
(empty)

Test 19

Verdict:

input
10
-1 -1 0 -1 -1 -1 -1 0 1 1

correct output
2

user output
(empty)

Test 20

Verdict:

input
10
0 0 -1 -1 1 -1 0 0 1 -1

correct output
1

user output
(empty)

Test 21

Verdict:

input
10
-1 -1 -1 0 0 1 -1 1 0 0

correct output
1

user output
(empty)

Test 22

Verdict:

input
10
0 0 -1 1 0 -1 0 0 1 -1

correct output
1

user output
(empty)

Test 23

Verdict:

input
10
-1 0 0 1 0 0 0 0 1 0

correct output
2

user output
(empty)

Test 24

Verdict:

input
10
0 0 1 1 1 0 1 -1 1 0

correct output
4

user output
(empty)

Test 25

Verdict:

input
10
-1 0 1 0 -1 0 1 0 1 0

correct output
2

user output
(empty)

Test 26

Verdict:

input
10
1 -1 -1 1 1 -1 1 1 -1 0

correct output
3

user output
(empty)

Test 27

Verdict:

input
10
-1 1 -1 1 1 -1 -1 1 1 -1

correct output
1

user output
(empty)

Test 28

Verdict:

input
10
-1 0 -1 -1 -1 -1 -1 -1 -1 1

correct output
1

user output
(empty)

Test 29

Verdict:

input
10
1 0 -1 0 0 -1 0 1 -1 0

correct output
1

user output
(empty)

Test 30

Verdict:

input
10
-1 1 0 0 -1 1 1 1 0 1

correct output
4

user output
(empty)

Test 31

Verdict:

input
10
1 1 -1 -1 0 0 1 0 1 -1

correct output
2

user output
(empty)

Test 32

Verdict:

input
10
1 1 0 1 0 1 0 1 1 0

correct output
6

user output
(empty)

Test 33

Verdict:

input
10
-1 0 -1 1 1 1 1 -1 1 -1

correct output
3

user output
(empty)

Test 34

Verdict:

input
10
-1 0 1 1 -1 -1 1 -1 -1 0

correct output
2

user output
(empty)

Test 35

Verdict:

input
10
-1 -1 -1 1 0 1 -1 0 1 1

correct output
3

user output
(empty)

Test 36

Verdict:

input
10
0 1 1 -1 -1 -1 1 0 0 0

correct output
2

user output
(empty)

Test 37

Verdict:

input
10
-1 1 -1 -1 0 0 -1 0 -1 1

correct output
1

user output
(empty)

Test 38

Verdict:

input
10
-1 1 0 0 0 0 1 -1 -1 -1

correct output
1

user output
(empty)

Test 39

Verdict:

input
10
-1 -1 -1 1 -1 1 1 1 -1 1

correct output
3

user output
(empty)

Test 40

Verdict:

input
10
0 -1 -1 -1 1 1 1 1 0 1

correct output
4

user output
(empty)

Test 41

Verdict:

input
10
1 -1 0 1 0 0 0 -1 1 -1

correct output
1

user output
(empty)

Test 42

Verdict:

input
10
-1 0 -1 1 0 -1 0 0 0 -1

correct output
1

user output
(empty)

Test 43

Verdict:

input
10
-1 -1 1 0 1 -1 -1 -1 1 -1

correct output
2

user output
(empty)

Test 44

Verdict:

input
10
1 0 0 -1 1 -1 -1 1 0 0

correct output
1

user output
(empty)

Test 45

Verdict:

input
10
1 1 0 -1 1 1 1 -1 0 0

correct output
4

user output
(empty)

Test 46

Verdict:

input
10
1 0 -1 1 -1 0 0 1 -1 -1

correct output
1

user output
(empty)

Test 47

Verdict:

input
10
0 1 -1 0 1 1 1 0 -1 -1

correct output
3

user output
(empty)

Test 48

Verdict:

input
10
0 0 1 -1 0 1 -1 0 0 -1

correct output
1

user output
(empty)

Test 49

Verdict:

input
10
-1 0 1 1 0 -1 1 0 -1 1

correct output
2

user output
(empty)

Test 50

Verdict:

input
10
-1 1 0 1 -1 -1 -1 -1 1 0

correct output
2

user output
(empty)

Test 51

Verdict:

input
3
-10 -5 -2

correct output
-2

user output
(empty)