-
-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathSockMerchant.java
More file actions
31 lines (29 loc) 路 710 Bytes
/
Copy pathSockMerchant.java
File metadata and controls
31 lines (29 loc) 路 710 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
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int c[] = new int[n];
for(int c_i=0; c_i < n; c_i++){
c[c_i] = in.nextInt();
}
Arrays.sort(c);
int a=c[0],pairs=0;
boolean flag=true;
for(int i=1;i<n;i++) {
if(flag&&c[i]==a) {
pairs++;
flag=false;
}
else{
a=c[i];
flag=true;
}
}
System.out.println(pairs);
}
}