#include <bits/stdc++.h> #define pb push_back #define fi first #define se second #define sz(x) (int)x.size() #define cat(x) cerr << #x << " = " << x << endl #define IOS cin.tie(0); ios_base::sync_with_stdio(0) using ll = long long; using namespace std; map <int, int> m[2]; int main() { int n; scanf("%d", &n); while (n--) { int a, b, c; cin >> a >> b >> c; m[--a][c - b]++; } int res = 0; for (auto [key, val] : m[0]) res += min(val, m[1][key]); printf("%d\n", res); 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 | #include <bits/stdc++.h> #define pb push_back #define fi first #define se second #define sz(x) (int)x.size() #define cat(x) cerr << #x << " = " << x << endl #define IOS cin.tie(0); ios_base::sync_with_stdio(0) using ll = long long; using namespace std; map <int, int> m[2]; int main() { int n; scanf("%d", &n); while (n--) { int a, b, c; cin >> a >> b >> c; m[--a][c - b]++; } int res = 0; for (auto [key, val] : m[0]) res += min(val, m[1][key]); printf("%d\n", res); return 0; } |