-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCHEGLOVE.java
More file actions
50 lines (46 loc) · 933 Bytes
/
CHEGLOVE.java
File metadata and controls
50 lines (46 loc) · 933 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
44
45
46
47
48
49
50
import java.util.Scanner;
public class CHEGLOVE
{
public static void main(String[] args) {
Scanner scan=new Scanner(System.in);
int t=scan.nextInt();
for(int t1=0;t1<t;t1++)
{
int n=scan.nextInt();
int[] l=new int[n];
int[] g= new int[n];
for(int i=0;i<n;i++)
l[i]=scan.nextInt();
for(int i=0;i<n;i++)
g[i]=scan.nextInt();
boolean front=isFront(l,g);
boolean back=isBack(l,g);
if(front&&back)
System.out.println("both");
else if(front)
System.out.println("front");
else if(back)
System.out.println("back");
else
System.out.println("none");
}
}
static boolean isFront(int[] l,int[] g)
{
for(int i=0;i<l.length;i++)
{
if(l[i]>g[i])
return false;
}
return true;
}
static boolean isBack(int[] l,int[] g)
{
for(int i=0;i<l.length;i++)
{
if(l[i]>g[n-i-1])
return false;
}
return true;
}
}