#include <bits/stdc++.h>
using namespace std;
int n, r, w, t, wynik;
pair<int,int> k[2000005];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(NULL); cout.tie(NULL);
cin >> n;
for(int i=0; i<n; i++){
cin >> r >> w >> t;
k[w+1000000-t].first++;
if(r==1) k[w+1000000-t].second++;
}
for(int i=0; i<=2000000; i++) if(k[i].first>1) wynik+=min(k[i].first-k[i].second, k[i].second);
cout << wynik;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <bits/stdc++.h> using namespace std; int n, r, w, t, wynik; pair<int,int> k[2000005]; int main(){ ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin >> n; for(int i=0; i<n; i++){ cin >> r >> w >> t; k[w+1000000-t].first++; if(r==1) k[w+1000000-t].second++; } for(int i=0; i<=2000000; i++) if(k[i].first>1) wynik+=min(k[i].first-k[i].second, k[i].second); cout << wynik; } |
English