#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define dod 1000009
using namespace std;
int n, r, w, t, wynik, tab[3][2*dod];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
cin>>n;
for(int i=0; i<n; i++){
cin>>r>>w>>t;
wynik-=min(tab[1][dod+w-t], tab[2][dod+w-t]);
tab[r][dod+w-t]++;
wynik+=min(tab[1][dod+w-t], tab[2][dod+w-t]);
}
cout<<wynik<<"\n";
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #include<bits/stdc++.h> #define mp make_pair #define pb push_back #define dod 1000009 using namespace std; int n, r, w, t, wynik, tab[3][2*dod]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); cin>>n; for(int i=0; i<n; i++){ cin>>r>>w>>t; wynik-=min(tab[1][dod+w-t], tab[2][dod+w-t]); tab[r][dod+w-t]++; wynik+=min(tab[1][dod+w-t], tab[2][dod+w-t]); } cout<<wynik<<"\n"; return 0; } |
English