-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAtcoder50B.java
More file actions
26 lines (25 loc) · 1.01 KB
/
Copy pathAtcoder50B.java
File metadata and controls
26 lines (25 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Atcoder50B {
public static void main(String[] args)throws Exception {
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt((input).readLine());
int [] problems = new int[n];
int sum = 0;
StringTokenizer tokn = new StringTokenizer(input.readLine());
for (int i = 0; i < n; i++) {
problems[i] = Integer.parseInt(tokn.nextToken());
sum += problems[i];
}
int m = Integer.parseInt((input).readLine());
StringBuilder out = new StringBuilder();
for (int i = 0; i < m; i++) {
tokn = new StringTokenizer(input.readLine());
int p1 = Integer.parseInt(tokn.nextToken());
int m1 = Integer.parseInt(tokn.nextToken());
out.append((sum - problems[p1 - 1]) + m1).append("\n");
}
System.out.println(out);
}
}