#include <bits/stdc++.h>
using namespace std;
void imax(int &a, int b){
a=max(a, b);
}
void imin(int &a, int b){
a=min(a, b);
}
void lmax(long long &a, long long b){
a=max(a, b);
}
void lmin(long long &a, long long b){
a=min(a, b);
}
/*
WARNING: I'm using strange bracket style!
*/
map <int, int> M[2];
int q, x, y, z, res;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int q;
cin>>q;
while (q--)
cin>>z>>x>>y, M[z-1][x-y]++;
for (auto i: M[0])
res+=min(M[1][i.first], M[0][i.first]);
cout<<res<<"\n";
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 29 30 31 32 33 | #include <bits/stdc++.h> using namespace std; void imax(int &a, int b){ a=max(a, b); } void imin(int &a, int b){ a=min(a, b); } void lmax(long long &a, long long b){ a=max(a, b); } void lmin(long long &a, long long b){ a=min(a, b); } /* WARNING: I'm using strange bracket style! */ map <int, int> M[2]; int q, x, y, z, res; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int q; cin>>q; while (q--) cin>>z>>x>>y, M[z-1][x-y]++; for (auto i: M[0]) res+=min(M[1][i.first], M[0][i.first]); cout<<res<<"\n"; return 0; } |
English