// Example program
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
map<int,map<int,int>>M;
for(int i=0;i<n;i++){
int a,b,c;
cin>>a>>b>>c;
M[b-c][a]++;
}
int res=0;
for(auto& m:M)
res+=min(m.second[1],m.second[2]);
cout<<res<<endl;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | // Example program #include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; map<int,map<int,int>>M; for(int i=0;i<n;i++){ int a,b,c; cin>>a>>b>>c; M[b-c][a]++; } int res=0; for(auto& m:M) res+=min(m.second[1],m.second[2]); cout<<res<<endl; } |
English