# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
799688 | 2023-07-31T20:15:15 Z | n3rm1n | Exhibition (JOI19_ho_t2) | C++17 | 0 ms | 212 KB |
#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 --; } else { vector < long long >::iterator it = upper_bound(v.begin(), v.end(), x); if(it == v.end())continue; long long num = *it, index = it - v.begin(); v[index] = x; } } 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 */
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 0 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |