#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int dostawy, typ, garaz, czas, odwolania=0;
cin >> dostawy;
vector <pair <int, int>> opis[3];
for (int i=0; i < dostawy; i++) {
cin >> typ >> garaz >> czas;
opis[typ].push_back({garaz, czas});
}
for (auto samo1 : opis[1]){
int i = 0;
for (auto samo2 : opis[2]) {
if (samo1.second + samo2.first == samo1.first + samo2.second) {
odwolania++;
opis[2].erase(opis[2].begin() + i);
}
i++;
}
}
cout << odwolania;
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 30 31 32 33 34 35 | #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int dostawy, typ, garaz, czas, odwolania=0; cin >> dostawy; vector <pair <int, int>> opis[3]; for (int i=0; i < dostawy; i++) { cin >> typ >> garaz >> czas; opis[typ].push_back({garaz, czas}); } for (auto samo1 : opis[1]){ int i = 0; for (auto samo2 : opis[2]) { if (samo1.second + samo2.first == samo1.first + samo2.second) { odwolania++; opis[2].erase(opis[2].begin() + i); } i++; } } cout << odwolania; return 0; } |
English