-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolve.java
More file actions
64 lines (50 loc) · 1.4 KB
/
solve.java
File metadata and controls
64 lines (50 loc) · 1.4 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class solve {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
int[][] powers = new int[N][100];
int[] line = new int[N];
int start = scanner.nextInt();
for(int i = 0;i < N - 1;i++){
int M = scanner.nextInt();
line[i] = M;
for (int j = 0; j < M; j++) {
powers[i][j] = scanner.nextInt();
}
}
List<List<Integer>> sol = new ArrayList<>();
List<Integer> linee = new ArrayList<>();
Map<List<Integer>,Integer> ga = new HashMap<>();
int answ = 0;
for(int i = start;i < N - 1;i++){
linee.clear();
for (int j = 0; j < 4; j++) {
if(powers[i][j] != 0){
linee.add(powers[i][j]);
}
//System.out.println(powers[i][j]);
}
//System.out.println(linee);
int max = getbig(linee);
i += max - 1;
//System.out.println(max + " " + i);
answ ++;
}
System.out.println(answ);
}
public static int getbig(List<Integer> line){
int max = 0;
for(Integer in : line){
max = Math.max(in,max);
}
return max;
}
public static void printMap(Map<List<Integer>, Integer> map) {
for (Map.Entry<List<Integer>, Integer> entry : map.entrySet()) {
System.out.println(entry.getKey() + ": " + entry.getValue());
}
}
}