#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
map<int,int>mapa[2];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, v, x, y, res=0;
cin >> n;
for(int i=1; i<=n; i++){
cin >> v >> x >> y;
mapa[v-1][x-y]++;
}
for(auto ii=mapa[0].begin(); ii!=mapa[0].end(); ii++) if(mapa[1][ii->first]) res+=min(ii->second, mapa[1][ii->first]);
cout << res;
return 0;
}
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 | #include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; map<int,int>mapa[2]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, v, x, y, res=0; cin >> n; for(int i=1; i<=n; i++){ cin >> v >> x >> y; mapa[v-1][x-y]++; } for(auto ii=mapa[0].begin(); ii!=mapa[0].end(); ii++) if(mapa[1][ii->first]) res+=min(ii->second, mapa[1][ii->first]); cout << res; return 0; } |
English