|
|
back to boardWhy Crash on test#2 ??? Posted by bigtik 24 Nov 2011 00:19 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class N1330 {
public static void main(String[] args) {
try { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(in.readLine()); int list[] = new int[n]; for (int i = 0; i < n; i++) list[i] = Integer.parseInt(in.readLine()); int q = Integer.parseInt(in.readLine()); for (int i = 0; i < q; i++) { int sum = 0; StringTokenizer tok = new StringTokenizer(in.readLine()); int start = Integer.parseInt(tok.nextToken())-1; int end = Integer.parseInt(tok.nextToken())-1; for (int j = start; j <= end; j++) sum += list[j]; System.out.println(sum); }
} catch(IOException e) {
}
} } |
|
|