// Jakub Rożek
// Samochody dostawcze [C]
// potyczki 2020
// O( n+w+t )
#include <bits/stdc++.h>
using namespace std;
int n,r,w,t,odp;
int tab[2000006][2];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin>>n;
while(n--)
{
cin>>r>>w>>t;
++tab[1000000+t-w][r-1];
}
for(int i=0; i<=2000000; ++i)
odp+=min(tab[i][0],tab[i][1]);
cout<<odp;
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 | // Jakub Rożek // Samochody dostawcze [C] // potyczki 2020 // O( n+w+t ) #include <bits/stdc++.h> using namespace std; int n,r,w,t,odp; int tab[2000006][2]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>n; while(n--) { cin>>r>>w>>t; ++tab[1000000+t-w][r-1]; } for(int i=0; i<=2000000; ++i) odp+=min(tab[i][0],tab[i][1]); cout<<odp; return(0); } |
English