#include <bits/stdc++.h> using namespace std; int t1[20000100], t2[2000100],k; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; for(int i=0; i<n; ++i) { int a,b,c; cin>>a>>b>>c; if(a==1) { t1[(b-c)+1000000]++; } else { t2[(b-c)+1000000]++; } } for(int i=0; i<=2000000; ++i) { k+=min(t1[i],t2[i]); } cout<<k; 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 | #include <bits/stdc++.h> using namespace std; int t1[20000100], t2[2000100],k; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin>>n; for(int i=0; i<n; ++i) { int a,b,c; cin>>a>>b>>c; if(a==1) { t1[(b-c)+1000000]++; } else { t2[(b-c)+1000000]++; } } for(int i=0; i<=2000000; ++i) { k+=min(t1[i],t2[i]); } cout<<k; return 0; } |