#include<bits/stdc++.h>
using namespace std;
int licz[3000005][2];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t;
cin>>t;
while(t--)
{
int a,b,c;
cin>>a>>b>>c;
licz[b-c+1000000][--a]++;
}
int zlicz = 0;
for(int x=0;x<=3000000;x++)
zlicz += min(licz[x][0] , licz[x][1]);
cout<<zlicz;
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include<bits/stdc++.h> using namespace std; int licz[3000005][2]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int t; cin>>t; while(t--) { int a,b,c; cin>>a>>b>>c; licz[b-c+1000000][--a]++; } int zlicz = 0; for(int x=0;x<=3000000;x++) zlicz += min(licz[x][0] , licz[x][1]); cout<<zlicz; return 0; } |
English