-
Notifications
You must be signed in to change notification settings - Fork 2
/
Tech.java
33 lines (28 loc) · 1.1 KB
/
Tech.java
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
27
28
29
30
31
32
33
// Success in 0.61s
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;
public class Tech{
public static void main(String[] args) throws IOException {
// Scanner sc = new Scanner(System.in);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
// String[] line = br.readLine().split(" ");
int n = Integer.parseInt(st.nextToken());
int numQuery = Integer.parseInt(st.nextToken());
int[] locations = new int[n];
st = new StringTokenizer(br.readLine());
for(int i = 0; i < n; i++) locations[i] = Integer.parseInt(st.nextToken());
while(numQuery-- > 0){
// line = br.readLine().split(" ");
st = new StringTokenizer(br.readLine());
int x = Integer.parseInt(st.nextToken());
int y = Integer.parseInt(st.nextToken()) - 1;
int z = Integer.parseInt(st.nextToken());
if(x == 1) locations[y] = z;
else System.out.println(Math.abs(locations[y] - locations[z - 1]));
}
br.close();
}
}