#include <iostream>
#include <map>
#include <algorithm>
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
std::map<int, int> positions[2];
int n;
std::cin >> n;
for (int i = 0; i < n; ++i) {
int r, w, t;
std::cin >> r >> w >> t;
++positions[r - 1][w - t];
}
int rejected = 0;
for (auto e : positions[0]) {
rejected += std::min(positions[1][e.first], e.second);
}
std::cout << rejected << std::endl;
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 | #include <iostream> #include <map> #include <algorithm> int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::map<int, int> positions[2]; int n; std::cin >> n; for (int i = 0; i < n; ++i) { int r, w, t; std::cin >> r >> w >> t; ++positions[r - 1][w - t]; } int rejected = 0; for (auto e : positions[0]) { rejected += std::min(positions[1][e.first], e.second); } std::cout << rejected << std::endl; return 0; } |
English