Submission #109456

#TimeUsernameProblemLanguageResultExecution timeMemory
109456wasylExhibition (JOI19_ho_t2)C++11
100 / 100
71 ms4496 KiB
#pragma GCC optimize("O3") /*{{{*/ #include <bits/stdc++.h> #ifdef LOCAL int c_ = 0; #define cout (c_?cerr:cout) #define debug(...) \ {if(!c_++)cerr<<"\033[96;1m"; \ __VA_ARGS__; \ if(!--c_)cerr<<"\033[0m";} #else #define debug(...) {} #endif #define assrt(...) debug(\ if (not (__VA_ARGS__)) \ exit((cerr << __LINE__ << ": " << #__VA_ARGS__ << '\n', 0));\ ) #define st first #define nd second #define all(...) (__VA_ARGS__).begin(), (__VA_ARGS__).end() using namespace std; using ll = long long; template < typename t > using V = vector< t >; template < typename t, size_t s > using A = array< t, s >; void print() {cout << '\n';} template< typename t, typename... v > void print(const t& a, const v&... b) {cout << a << (sizeof...(b)?" ":""); print(b...);} template< typename t > void print_range(t a, const t& b) { while (a != b) cout << (*a++) << ' '; cout << '\n';} #define dump(...) debug(print(#__VA_ARGS__,'=',__VA_ARGS__)) #define dump_range(...) debug(cerr<<#__VA_ARGS__ << ": "; print_range(__VA_ARGS__)) /*}}}*/ constexpr int nax = 1e5, maxm = 1e5; int n, m, ilo[maxm]; pair< int, int > tab[nax + 1]; bool spr(const int v) { int pt = m - 1 - v + 1; for (int i = 0; i < n and pt < m; ++i) if (tab[i].nd <= ilo[pt]) ++pt; return pt == m; } int32_t main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m; for (int i = 0; i < n; ++i) cin >> tab[i].nd >> tab[i].st; sort(begin(tab), begin(tab) + n); for (int i = 0; i < m; ++i) cin >> ilo[i]; sort(begin(ilo), begin(ilo) + m); int lo = 0, hi = min(n, m); while (lo < hi) { int mi = (lo + hi + 1) / 2; if (spr(mi)) lo = mi; else hi = mi - 1; } print(lo); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...