# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
227363 | bharat2002 | Exhibition (JOI19_ho_t2) | C++14 | 387 ms | 24552 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*input
8 8
15 1
12 3
14 4
22 6
23 10
5 16
18 19
13 20
11
24
2
21
8
9
17
7
*/
#include<bits/stdc++.h>
using namespace std;
const int N=1e5 + 100;
const int mod=1e9 + 7;
#define int long long
const int inf=1e18;
#define pii pair<int, int>
#define f first
#define s second
#define mp make_pair
#define FOR(i, n) for(int i=1;i<=n;i++)
#define TRACE(x) cerr << #x << " = " << x << endl
//Trace prints the name of the variable and the value.
int n, m, arr[N];
struct comp
{
bool operator()(pii a, pii b)
{
if(a.f==b.f) return a.s<=b.s;return a.f<b.f;
}
};
priority_queue< pii, vector< pii>, comp > pq;
bool sf(int a, int b)
{
return a>b;
}
signed main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
cin>>n>>m;map<int, int> vals;
for(int i=1;i<=n;i++)
{
int ss, v;cin>>ss>>v;pq.push(mp(v, ss));vals[ss]=vals[v]=0;
}
for(int i=1;i<=m;i++) {cin>>arr[i];vals[arr[i]]=0;}
/* int ct=1;
for(auto &it:vals) it.s=ct++;
while(!pq.empty())
{
cout<<vals[pq.top().s]<<" "<<vals[pq.top().f]<<endl;pq.pop();
}
for(int i=1;i<=m;i++) cout<<vals[arr[i]]<<endl;return 0;*/
sort(arr+1, arr+m+1, sf);;
int ans=0;
for(int i=1;i<=m;i++)
{
while(!pq.empty()&&pq.top().s>arr[i]) pq.pop();
if(pq.empty()) break;
ans++;pq.pop();
}
cout<<ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |