-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompare the Triplets.java
More file actions
44 lines (36 loc) · 1.03 KB
/
Compare the Triplets.java
File metadata and controls
44 lines (36 loc) · 1.03 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
import java.util.Scanner;
import java.util.ArrayList;
class Main{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
ArrayList<Integer> c=new ArrayList<>();
ArrayList<Integer> d=new ArrayList<>();
while(sc.hasNext())
{
if(sc.hasNextInt())
{
c.add(sc.nextInt());
}
else
{
sc.next();
}
}
for(int i=c.size()/2;i<c.size();i++)
{
d.add(c.get(i));
}
for(int i=0;i<d.size();i++)
{
c.remove(c.size()-1);
}
int a=0,b=0;
for(int i=0;i<c.size();i++){
if(c.get(i)>d.get(i))
a++;
else if(c.get(i)<d.get(i))
b++;
}
System.out.println(a+" "+b);
}
}