#include <bits/stdc++.h> using namespace std; #define inf 1000000007 int n, r, w, t, ile[3][2000007], do_usuniecia; int main () { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i=1; i<=n; i++) { cin >> r >> w >> t; ile[r][w-t+1000000]++; } for (int i=0; i<=2000000; i++) do_usuniecia += min(ile[1][i], ile[2][i]); cout << do_usuniecia << "\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 | #include <bits/stdc++.h> using namespace std; #define inf 1000000007 int n, r, w, t, ile[3][2000007], do_usuniecia; int main () { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i=1; i<=n; i++) { cin >> r >> w >> t; ile[r][w-t+1000000]++; } for (int i=0; i<=2000000; i++) do_usuniecia += min(ile[1][i], ile[2][i]); cout << do_usuniecia << "\n"; return 0; } |