#include<bits/stdc++.h>
using namespace std;
map<int,int> m[3];
vector<int> dif;
int n;
int wyn;
void wczytaj() {
cin >> n;
while(n--) {
int typ,x,d; cin >> typ >> x >> d;
m[typ][x-d]++;
dif.push_back(x-d);
}
}
void calc() {
for(auto x : dif) {
wyn += min(m[1][x],m[2][x]);
m[1][x]=0;
}
}
void wypisz() {
cout << wyn;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
wczytaj();
calc();
wypisz();
}
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 30 31 32 33 34 35 | #include<bits/stdc++.h> using namespace std; map<int,int> m[3]; vector<int> dif; int n; int wyn; void wczytaj() { cin >> n; while(n--) { int typ,x,d; cin >> typ >> x >> d; m[typ][x-d]++; dif.push_back(x-d); } } void calc() { for(auto x : dif) { wyn += min(m[1][x],m[2][x]); m[1][x]=0; } } void wypisz() { cout << wyn; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); wczytaj(); calc(); wypisz(); } |
English