#include<bits/stdc++.h> typedef long long ll; typedef std::pair<ll, ll> pll; typedef std::pair<int, int> pii; #define all(x) (x).begin(),(x).end() #define debug std::cout<<"ok"<<std::endl main () { int n; std::cin>>n; std::vector<std::vector<int> > V(2000001, {0,0}); while(n--) { int a,b,c; std::cin>>a>>b>>c; V[b-c+1000000][a-1]++; } int W=0; for (auto a:V) W+=std::min(a[0], a[1]); std::cout<<W<<std::endl; }
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<bits/stdc++.h> typedef long long ll; typedef std::pair<ll, ll> pll; typedef std::pair<int, int> pii; #define all(x) (x).begin(),(x).end() #define debug std::cout<<"ok"<<std::endl main () { int n; std::cin>>n; std::vector<std::vector<int> > V(2000001, {0,0}); while(n--) { int a,b,c; std::cin>>a>>b>>c; V[b-c+1000000][a-1]++; } int W=0; for (auto a:V) W+=std::min(a[0], a[1]); std::cout<<W<<std::endl; } |