3156 | 2023-02-21 00:46:03 | Ancsa | Zsonglőrködés | cpp11 | Accepted 100/100 | 444ms | 45664 KiB |
#include <bits/stdc++.h>
/*
#include <algorithm>
#include <fstream>
#include <iostream>
#include <map>
#include <vector>
*/
/*
9
1 3
2 4
8 10
1 7
2 7
2 3
9 11
3 9
3 8
*/
using namespace std;
bool elobb(pair<int, int> x, pair<int, int > y)
{
if(x.second==y.second)
return x.first<y.first;
return x.second<y.second;
}
int main()
{
int N;
vector<pair<int, int> > v;
cin >> N;
for (int i = 0; i < N; i++) {
int a, b;
cin >> a >> b;
v.push_back({a, b});
}
sort(v.begin(), v.end(), elobb);
/*
for(pair<int,int> x : v)
cout<<x.first<<"--"<<x.second<<endl;
cout<<endl;
*/
map<int, int> k;
int tot = N; //kezdetben N nap
//for(int i=0;i<N;i++)
// cout<<k[v[i].first]<<" "<<k[v[i].second]<<endl;
for (int i = 0; i < N; i++)
{
// cout<<i<<"***"<<tot<<" "<<k[v[i].first]<<" "<<k[v[i].second];
if (k[v[i].first] > 0)
{
k[v[i].first]--;
tot--;
}
k[v[i].second]++;
// cout<<"-->"<<k[v[i].first]<<" "<<k[v[i].second]<<endl;
}
cout << tot << endl;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1852 KiB | ||||
2 | Accepted | 3ms | 2044 KiB | ||||
subtask2 | 20/20 | ||||||
3 | Accepted | 4ms | 2712 KiB | ||||
4 | Accepted | 104ms | 14572 KiB | ||||
5 | Accepted | 284ms | 33168 KiB | ||||
6 | Accepted | 345ms | 39104 KiB | ||||
7 | Accepted | 391ms | 43388 KiB | ||||
8 | Accepted | 404ms | 43692 KiB | ||||
9 | Accepted | 386ms | 43908 KiB | ||||
10 | Accepted | 405ms | 44152 KiB | ||||
11 | Accepted | 391ms | 43996 KiB | ||||
subtask3 | 35/35 | ||||||
12 | Accepted | 3ms | 3676 KiB | ||||
13 | Accepted | 2ms | 3732 KiB | ||||
14 | Accepted | 3ms | 3880 KiB | ||||
15 | Accepted | 3ms | 3972 KiB | ||||
16 | Accepted | 3ms | 3956 KiB | ||||
17 | Accepted | 3ms | 4360 KiB | ||||
18 | Accepted | 3ms | 4304 KiB | ||||
19 | Accepted | 3ms | 4460 KiB | ||||
20 | Accepted | 3ms | 4428 KiB | ||||
subtask4 | 45/45 | ||||||
21 | Accepted | 4ms | 4920 KiB | ||||
22 | Accepted | 61ms | 5756 KiB | ||||
23 | Accepted | 293ms | 34952 KiB | ||||
24 | Accepted | 180ms | 8720 KiB | ||||
25 | Accepted | 444ms | 44996 KiB | ||||
26 | Accepted | 201ms | 8764 KiB | ||||
27 | Accepted | 416ms | 45264 KiB | ||||
28 | Accepted | 200ms | 9108 KiB | ||||
29 | Accepted | 412ms | 45664 KiB |