-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOrder.java
48 lines (36 loc) · 953 Bytes
/
Order.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Order
{
public static void main(String[] argv) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
long n = Integer.parseInt(getLine(br));
long current = 0;
int cnt = 0;
while (n-- > 0) {
long c = Long.parseLong(getLine(br));
if (cnt == 0) {
current = c;
cnt = 1;
}
else if (current == c) {
cnt++;
}
else {
cnt--;
}
}
System.out.println(current+" ");
}
public static String getLine(BufferedReader br) {
String s = null;
try {
s = br.readLine();
}
catch (Exception e) {
}
return s;
}
}