#include <iostream> #include <vector> #include <algorithm> int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0); int n; std::cin >> n; std::vector<std::vector<int>> count(2, std::vector<int>(2000000)); for (int i = 0; i < n; ++i) { int r; int w, t; std::cin >> r >> w >> t; ++count[r - 1][t - w + 1000000]; } int result = 0; for (int i = 0; i < 2000000; ++i) { result += std::min(count[0][i], count[1][i]); } std::cout << result << 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 24 25 | #include <iostream> #include <vector> #include <algorithm> int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0); int n; std::cin >> n; std::vector<std::vector<int>> count(2, std::vector<int>(2000000)); for (int i = 0; i < n; ++i) { int r; int w, t; std::cin >> r >> w >> t; ++count[r - 1][t - w + 1000000]; } int result = 0; for (int i = 0; i < 2000000; ++i) { result += std::min(count[0][i], count[1][i]); } std::cout << result << std::endl; return 0; } |