#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); int cars; cin >> cars; vector <int> diag1 (2000001); vector <int> diag2 (2000001); int r, w, t; while (cars--) { cin >> r >> w >> t; if (r == 1) diag1[w - t + 1000000]++; else diag2[w - t + 1000000]++; } int licz = 0; for (int i = 0; i <= diag1.size(); i++) if (diag1[i] && diag2[i]) licz += min(diag1[i], diag2[i]); cout << licz; }
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 | #include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); int cars; cin >> cars; vector <int> diag1 (2000001); vector <int> diag2 (2000001); int r, w, t; while (cars--) { cin >> r >> w >> t; if (r == 1) diag1[w - t + 1000000]++; else diag2[w - t + 1000000]++; } int licz = 0; for (int i = 0; i <= diag1.size(); i++) if (diag1[i] && diag2[i]) licz += min(diag1[i], diag2[i]); cout << licz; } |