Submission details
Task:Array
Sender:lazycoder
Submission time:2015-09-30 19:00:12 +0300
Language:Java
Status:READY
Result:
Test results
testverdicttime
#10.32 sdetails
#20.23 sdetails
#30.21 sdetails
#40.27 sdetails
#50.19 sdetails
#60.30 sdetails
#70.30 sdetails
#80.31 sdetails
#90.32 sdetails
#100.31 sdetails
#110.32 sdetails
#120.33 sdetails
#130.31 sdetails
#140.32 sdetails
#150.32 sdetails
#160.33 sdetails
#170.35 sdetails
#180.33 sdetails
#190.34 sdetails
#200.32 sdetails
#210.26 sdetails

Code

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author bkotte
 */
import java.util.*;
import java.io.*;

public class RangeSum {

    public static void main(String args[]) {
        ArrayList<Integer> input = new ArrayList();
        ArrayList<Integer> psum = new ArrayList();
        HashMap<Integer, Integer> hashMap = new HashMap();

        IO io = new IO();
        int N = io.nextInt();
        int x = io.nextInt();
        int ps = 0;
        psum.add(0);
        hashMap.put(0, 1);
        for (int i = 0; i < N; i++) {
            int inp = io.nextInt();
            input.add(inp);
            ps = psum.get(i) + inp;
            psum.add(ps);
            if (hashMap.containsKey(ps)) {
                hashMap.put(ps, hashMap.get(ps) + 1);
            } else {
                hashMap.put(ps, 1);
            }
        }
        System.out.println(hashMap.get(ps - x)+1);
    }
}

Test details

Test 1

Verdict:

input
89384 -6
-1 9 -2 0 0 -1 5 0 -8 9 10 -6 ...

correct output
2029635

user output
2

Test 2

Verdict:

input
32688 -4
6 0 9 -10 -2 -2 -1 5 -5 -6 9 8...

correct output
321307

user output
12

Test 3

Verdict:

input
11023 2
5 0 -1 9 -10 3 10 -10 1 -3 -8 ...

correct output
146015

user output
11

Test 4

Verdict:

input
36884 -7
6 8 2 -4 1 7 1 -7 5 3 1 -6 1 -...

correct output
471565

user output
2

Test 5

Verdict:

input
2875 -6
-4 1 -6 -10 -2 -5 9 0 -2 9 -3 ...

correct output
9343

user output
2

Test 6

Verdict:

input
52346 -111
973 629 570 312 541 -117 332 7...

correct output
8791

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at RangeSum.main(RangeSum.java:38)

Test 7

Verdict:

input
55283 298
593 -881 937 901 -91 -622 632 ...

correct output
7351

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at RangeSum.main(RangeSum.java:38)

Test 8

Verdict:

input
93592 -589
951 -193 -855 -692 926 -602 -6...

correct output
26431

user output
3

Test 9

Verdict:

input
98149 942
-816 178 196 -503 654 -474 -64...

correct output
37659

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at RangeSum.main(RangeSum.java:38)

Test 10

Verdict:

input
79573 -346
-161 619 720 182 726 452 -63 -...

correct output
19690

user output
5

Test 11

Verdict:

input
100000 -9229
-6207 -4894 -1224 8410 -2954 4...

correct output
1969

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at RangeSum.main(RangeSum.java:38)

Test 12

Verdict:

input
100000 4655
134 4684 8364 -7381 -1874 3429...

correct output
2353

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at RangeSum.main(RangeSum.java:38)

Test 13

Verdict:

input
100000 -5901
-4907 7494 7673 -3917 -3223 -7...

correct output
2345

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at RangeSum.main(RangeSum.java:38)

Test 14

Verdict:

input
100000 -2507
-845 -6674 -3174 9309 -1411 53...

correct output
2242

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at RangeSum.main(RangeSum.java:38)

Test 15

Verdict:

input
100000 -4850
-9232 -2843 5422 -5336 -2835 -...

correct output
3753

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at RangeSum.main(RangeSum.java:38)

Test 16

Verdict:

input
100000 -745023
-561148 78606 440682 608892 -3...

correct output
27

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at RangeSum.main(RangeSum.java:38)

Test 17

Verdict:

input
100000 987216
602043 416718 216813 720665 -6...

correct output
41

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at RangeSum.main(RangeSum.java:38)

Test 18

Verdict:

input
100000 -140762
-813926 -641015 5926 -87604 -8...

correct output
43

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at RangeSum.main(RangeSum.java:38)

Test 19

Verdict:

input
100000 -828680
-53023 -23367 -91278 162438 82...

correct output
27

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at RangeSum.main(RangeSum.java:38)

Test 20

Verdict:

input
100000 -731243595
-728764339 -159138563 36776806...

correct output
0

user output
(empty)

Error:
Exception in thread "main" java.lang.NullPointerException
	at RangeSum.main(RangeSum.java:38)

Test 21

Verdict:

input
100000 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

correct output
5000050000

user output
100002