# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
799682 | n3rm1n | Exhibition (JOI19_ho_t2) | C++17 | 1 ms | 212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
//cout << x << endl;
//cout << (int)v.back() << endl;
if(x >= (int)v.back() && x <= -frames[sz-1])
{
v.push_back(x);
//cout << "in " << x << endl;
sz --;
}
else
{
vector < int >::iterator it = upper_bound(v.begin(), v.end(), x);
if(it == v.end())continue;
int num = *it, index = it - v.begin();
//cout << v[index] << " updated " << x << " on " << index << endl;
v[index] = x;
}
}
return (sz <= 0);
}
void bin_search()
{
int l = 0, r = n, 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;
}
컴파일 시 표준 에러 (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... |