# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
799685 | n3rm1n | Exhibition (JOI19_ho_t2) | C++17 | 1 ms | 212 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.
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAXN = 1e5 + 10;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
int n, m;
vector < pair < int , int > > g;
vector < int > frames;
void read()
{
cin >> n >> m;
int xx, yy;
for (int i = 1; i <= n; ++ i)
{
cin >> xx >> yy;
g.push_back(make_pair(yy, xx));
}
sort(g.begin(), g.end());
for (int i = 1; i <= m; ++ i)
{
cin >> xx;
frames.push_back(-xx);
}
sort(frames.begin(), frames.end());
}
vector < int > v;
bool check(int goal)
{
v.clear();
v.push_back(-1);
int x;
int sz = goal;
for (int i = 0; i < g.size(); ++ i)
{
x = g[i].second;
if(x >= (int)v.back() && x <= -frames[sz-1])
{
v.push_back(x);
sz --;
}
}
return (sz <= 0);
}
void bin_search()
{
int l = 1, r = m, mid, ans = 0;
while(l <= r)
{
mid = (l + r)/2;
if(check(mid))
{
ans = mid;
l = mid + 1;
}
else r = mid - 1;
}
cout << ans << endl;
}
int main()
{
speed();
read();
bin_search();
return 0;
}
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... |