Created
December 7, 2015 22:55
-
-
Save nomarlo/d4a82cf7a03944b1fdcd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Considerar que ninguno de los dos tiene más de una copia del mismo disco. | |
Solucón usando un set, se podría hacer de igual forma con un array lo que reduciria las consultas | |
de Log a constante. | |
**/ | |
#include <cstdio> | |
#include <iostream> | |
#include <cmath> | |
#include <algorithm> | |
#include <queue> | |
#include <stack> | |
#include <sstream> | |
#include <map> | |
#include <set> | |
using namespace std; | |
std::set<int>::iterator it; | |
set <int> B; | |
int n,m,aux,r; | |
long long int res; | |
int main(){ | |
scanf("%d %d",&n,&m); | |
while(n||m){ | |
r=0; | |
for(int i=0;i<n;i++){ | |
scanf("%d",&aux); | |
B.insert(aux); | |
} | |
for(int i=0;i<m;i++){ | |
scanf("%d",&aux); | |
it=B.find(aux); | |
if(it!=B.end()){ | |
r++; | |
B.erase(it); | |
} | |
} | |
if(!B.empty()) | |
B.clear(); | |
printf("%d\n",r); | |
scanf("%d %d",&n,&m); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment