3803 | 2023-03-03 08:51:29 | kohumark | Zsonglőrködés | cpp17 | Accepted 100/100 | 279ms | 45088 KiB |
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
bool elobb(pair<int,int> a, pair<int,int> b){
if(a.second==b.second) return a.first>b.first;
return a.second>b.second;
}
int main(){
cin.tie(0); ios_base::sync_with_stdio(false);
int n; cin >> n; vector<pair<int,int>> adat;
for(int i=0; i<n; i++){
int x,y; cin >> x >> y;
adat.push_back(make_pair(x,y));
}
sort(adat.begin(),adat.end(),elobb);
map<int,int> sol;
for(int i=0; i<adat.size(); i++){
if(sol[adat[i].second]>0){n--;sol[adat[i].second]--;}
sol[adat[i].first]++;
}
cout << n;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1828 KiB | ||||
2 | Accepted | 3ms | 2060 KiB | ||||
subtask2 | 20/20 | ||||||
3 | Accepted | 4ms | 2732 KiB | ||||
4 | Accepted | 67ms | 14520 KiB | ||||
5 | Accepted | 180ms | 33156 KiB | ||||
6 | Accepted | 224ms | 39432 KiB | ||||
7 | Accepted | 266ms | 43820 KiB | ||||
8 | Accepted | 254ms | 43956 KiB | ||||
9 | Accepted | 252ms | 44016 KiB | ||||
10 | Accepted | 256ms | 44224 KiB | ||||
11 | Accepted | 252ms | 44124 KiB | ||||
subtask3 | 35/35 | ||||||
12 | Accepted | 3ms | 3840 KiB | ||||
13 | Accepted | 2ms | 3896 KiB | ||||
14 | Accepted | 3ms | 4056 KiB | ||||
15 | Accepted | 3ms | 3892 KiB | ||||
16 | Accepted | 3ms | 4128 KiB | ||||
17 | Accepted | 3ms | 4028 KiB | ||||
18 | Accepted | 3ms | 4084 KiB | ||||
19 | Accepted | 3ms | 4188 KiB | ||||
20 | Accepted | 3ms | 4244 KiB | ||||
subtask4 | 45/45 | ||||||
21 | Accepted | 4ms | 4632 KiB | ||||
22 | Accepted | 25ms | 5572 KiB | ||||
23 | Accepted | 186ms | 34732 KiB | ||||
24 | Accepted | 71ms | 8476 KiB | ||||
25 | Accepted | 277ms | 44912 KiB | ||||
26 | Accepted | 81ms | 8864 KiB | ||||
27 | Accepted | 279ms | 45052 KiB | ||||
28 | Accepted | 81ms | 8800 KiB | ||||
29 | Accepted | 277ms | 45088 KiB |