-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTeamwork.java
More file actions
35 lines (27 loc) · 728 Bytes
/
Copy pathTeamwork.java
File metadata and controls
35 lines (27 loc) · 728 Bytes
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
import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Teamwork
{
public static void main(String[] argv) {
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int n = in.nextInt();
int prev = in.nextInt();
int cnt = 1;
n--;
// 1 1 2 3 3 3 10 10
while (n-- > 0) {
int c = in.nextInt();
if (c == prev) {
cnt++;
}
else { // prev != -1 && c != prev
System.out.print(cnt+" "+prev+" ");
prev = c;
cnt = 1;
}
}
System.out.println(cnt+" "+prev);
}
}