forked from chencorey/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSock Merchant.cpp
More file actions
39 lines (37 loc) · 819 Bytes
/
Sock Merchant.cpp
File metadata and controls
39 lines (37 loc) · 819 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
// https://www.hackerrank.com/contests/world-codesprint-7/challenges/sock-merchant
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
vector<int> socks;
int main() {
int N;
cin>>N;
for(int i = 0; i<N; i++)
{
int sock;
cin>>sock;
int found = -1;
for(int j = 0; j<socks.size(); j++)
{
if(sock==socks[j])
{
found = j;
break;
}
}
if(found>-1)
{
socks.erase(socks.begin()+found);
}
else
{
socks.push_back(sock);
}
}
cout << (N-(int)socks.size())/2;
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
return 0;
}