#include <bits/stdc++.h>
const int DELTA = 1500005;
using namespace std;
int n, a, b, c, res;
int t[3][2 * DELTA + 5];
int main() {
ios_base::sync_with_stdio(0);
cin >> n;
for(int i = 1; i <= n; i++) {
cin >> a >> b >> c;
t[a][DELTA + b - c]++;
}
for(int i = 0; i < 2 * DELTA; i++) res += min(t[1][i], t[2][i]);
cout << res;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include <bits/stdc++.h> const int DELTA = 1500005; using namespace std; int n, a, b, c, res; int t[3][2 * DELTA + 5]; int main() { ios_base::sync_with_stdio(0); cin >> n; for(int i = 1; i <= n; i++) { cin >> a >> b >> c; t[a][DELTA + b - c]++; } for(int i = 0; i < 2 * DELTA; i++) res += min(t[1][i], t[2][i]); cout << res; } |
English