# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
799816 | n3rm1n | Exhibition (JOI19_ho_t2) | C++17 | 51 ms | 7400 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 long long MAXN = 1e5 + 10;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
long long n, m;
vector < pair < long long , long long > > g;
vector < long long > frames;
void read()
{
cin >> n >> m;
long long xx, yy;
for (long long i = 1; i <= n; ++ i)
{
cin >> xx >> yy;
g.push_back(make_pair(yy, xx));
}
sort(g.begin(), g.end());
for (long long i = 1; i <= m; ++ i)
{
cin >> xx;
frames.push_back(-xx);
}
sort(frames.begin(), frames.end());
}
vector < long long > v;
bool check(long long goal)
{
v.clear();
v.push_back(-1);
long long x;
long long sz = goal-1;
for (long long i = 0; i < g.size(); ++ i)
{
x = g[i].second;
if(/*x >= (long long)v.back() &&*/ x <= -frames[sz])
{
v.push_back(x);
sz --;
if(sz < 0)return true;
}
}
return (sz < 0);
}
void bin_search()
{
long long 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;
}
/**
10 10
978749728 144544247
765886828 382970504
724321206 775440108
793469869 329793955
744661733 757784475
737531928 772848949
880702330 298220471
886356598 234769581
756489712 541017091
976784156 205683907
498207927
462526472
688444509
591128229
744661733
421432475
299894333
737531928
39584784
724321206
10 10
44994472 57160841
127592536 57160841
60187289 57160841
224262980 801083909
297577794 801083909
521325580 801083909
802591211 801083909
333555245 57160841
362230938 57160841
52476098 57160841
465120061
652114335
652114335
465120061
467708607
874271777
467708607
467708607
874271777
465120061
*/
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... |