-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCRICSCR.java
More file actions
45 lines (41 loc) · 1.13 KB
/
CRICSCR.java
File metadata and controls
45 lines (41 loc) · 1.13 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
import java.util.Scanner;
public class CRICSCR
{
public static void main(String[] args)
{
Scanner scan=new Scanner(System.in);
int n,runs=0,wickets=0;
boolean allOut=false;
n=scan.nextInt();
int []r=new int[n];
int []w=new int[n];
for (int i=0;i<n ;i++ )
{
r[i]=scan.nextInt();
w[i]=scan.nextInt();
}
for (int i=0;i<n ;i++ )
{
if(runs<=r[i])
runs=r[i];
else{
System.out.println("NO");
System.exit(0);
}
if(wickets<=w[i]&&w[i]<=10)
wickets=w[i];
else{
System.out.println("NO");
System.exit(0);
}
if(allOut)
{
System.out.println("NO");
System.exit(0);
}
if(wickets==10)
allOut=true;
}
System.out.println("YES");
}
}