-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProblem4.java
More file actions
43 lines (39 loc) · 876 Bytes
/
Problem4.java
File metadata and controls
43 lines (39 loc) · 876 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
36
37
38
39
40
41
42
43
import java.util.*;
import java.lang.*;
import java.io.*;
public class Problem4
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner scan = new Scanner(System.in);
int N, P;
N = scan.nextInt();
P = scan.nextInt();
int ans = 0;
for (int i = 0; i < P; i++) {
int M = scan.nextInt();
Vector<Integer> v = new Vector<>();
for (int j = 0; j < M; j++) {
int x;
x = scan.nextInt();
v.add(x);
}
int bessie = scan.nextInt();
int L = 0, R = v.size(); //change is here
while (L < R) {
int mid = (L + R) / 2;
if (v.get(mid) == bessie) {
ans++;
break;
}
if (v.get(mid) < bessie) {
L = mid + 1;
}
else {
R = mid - 1;
}
}
}
System.out.println(ans);
}
}