Skip to content

Instantly share code, notes, and snippets.

@esthicodes
Created August 24, 2021 01:16
Show Gist options
  • Save esthicodes/0f2b09f85fa4caa4405389a45f03043e to your computer and use it in GitHub Desktop.
Save esthicodes/0f2b09f85fa4caa4405389a45f03043e to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() {
int n;
scanf("%d",&n);
int arr[101];
for(int i=0;i<101;i++){
arr[i]=0;
}
for(int i=0;i<n;i++){
int j;
scanf("%d",&j);
arr[j] += 1;
}
int total=0;
for(int i=0;i<101;i++){
if(arr[i]> 1){
if(arr[i] % 2 == 0) total += (arr[i] / 2);
else total += ((arr[i]-1) / 2);
}
}
printf("%d",total);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment