#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)x.size()
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
ll n;
cin >> n;
multiset<ll> m[2];
for(int i = 0; i < n; i++) {
ll r, w, t;
cin >> r >> w >> t;
m[r-1].insert(w-t);
}
ll ans = 0;
for(ll i = -1'100'000; i < 1'100'000; i++) {
ans += min(m[0].count(i), m[1].count(i));
}
cout << ans << '\n';
}
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> #define ll long long #define sz(x) (int)x.size() using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); ll n; cin >> n; multiset<ll> m[2]; for(int i = 0; i < n; i++) { ll r, w, t; cin >> r >> w >> t; m[r-1].insert(w-t); } ll ans = 0; for(ll i = -1'100'000; i < 1'100'000; i++) { ans += min(m[0].count(i), m[1].count(i)); } cout << ans << '\n'; } |
English