#include <bits/stdc++.h> using namespace std; int main() { int n, d, w, t; cin >> n; vector <int> arr1 (2000001); vector <int> arr2 (2000001); for (int i = 0; i < 2000001; i++) { arr1[i] = 0; arr2[i] = 0; } while (n--) { cin >> d; cin >> w; cin >> t; w -= t; w += 1000000; // cout << w << endl; if ( d == 1 ) arr1[w]++; else arr2[w]++; } for ( int i = 0; i < 2000001; i++) { if ( arr1[i] && arr2[i] ) n += min(arr1[i], arr2[i]); } cout << ++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 23 24 25 26 27 28 29 30 31 32 | #include <bits/stdc++.h> using namespace std; int main() { int n, d, w, t; cin >> n; vector <int> arr1 (2000001); vector <int> arr2 (2000001); for (int i = 0; i < 2000001; i++) { arr1[i] = 0; arr2[i] = 0; } while (n--) { cin >> d; cin >> w; cin >> t; w -= t; w += 1000000; // cout << w << endl; if ( d == 1 ) arr1[w]++; else arr2[w]++; } for ( int i = 0; i < 2000001; i++) { if ( arr1[i] && arr2[i] ) n += min(arr1[i], arr2[i]); } cout << ++n; return 0; } |