#include <bits/stdc++.h>
using namespace std;
int proste[2000007][2];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int ile, kierunek, przesuniecie, czas, wynik=0;
cin>>ile;
for(int i=0; i<ile; i++)
{
cin>>kierunek>>przesuniecie>>czas;
proste[1000000+przesuniecie-czas][kierunek-1]++;
}
for(auto & i : proste)
{
wynik+=min(i[0], i[1]);
}
cout<<wynik;
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 | #include <bits/stdc++.h> using namespace std; int proste[2000007][2]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int ile, kierunek, przesuniecie, czas, wynik=0; cin>>ile; for(int i=0; i<ile; i++) { cin>>kierunek>>przesuniecie>>czas; proste[1000000+przesuniecie-czas][kierunek-1]++; } for(auto & i : proste) { wynik+=min(i[0], i[1]); } cout<<wynik; return 0; } |
English