#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define TRAV(i, a) for(auto & i : (a))
#define SZ(x) ((int)(x).size())
#define PR std::pair
#define MP std::make_pair
#define X first
#define Y second
typedef long long ll;
typedef std::pair<int, int> PII;
typedef std::vector<int> VI;
int main(){
std::ios_base::sync_with_stdio(false);
std::cin.tie(0);
int n;
std::cin >> n;
std::map<int, std::array<int, 2>> map;
FOR(i, n){
int r, w, t;
std::cin >> r >> w >> t;
map[w-t][r-1]++;
}
int ans = 0;
TRAV(pr, map) ans += std::min(pr.Y[0], pr.Y[1]);
std::cout << ans << "\n";
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 28 29 30 31 | #include <bits/stdc++.h> #define FOR(i, n) for(int i = 0; i < (n); ++i) #define REP(i, a, b) for(int i = (a); i < (b); ++i) #define TRAV(i, a) for(auto & i : (a)) #define SZ(x) ((int)(x).size()) #define PR std::pair #define MP std::make_pair #define X first #define Y second typedef long long ll; typedef std::pair<int, int> PII; typedef std::vector<int> VI; int main(){ std::ios_base::sync_with_stdio(false); std::cin.tie(0); int n; std::cin >> n; std::map<int, std::array<int, 2>> map; FOR(i, n){ int r, w, t; std::cin >> r >> w >> t; map[w-t][r-1]++; } int ans = 0; TRAV(pr, map) ans += std::min(pr.Y[0], pr.Y[1]); std::cout << ans << "\n"; return 0; } |
English