Submission #799682

#TimeUsernameProblemLanguageResultExecution timeMemory
799682n3rm1nExhibition (JOI19_ho_t2)C++17
0 / 100
1 ms212 KiB
#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; }

Compilation message (stderr)

joi2019_ho_t2.cpp: In function 'bool check(int)':
joi2019_ho_t2.cpp:38:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for (int i = 0; i < g.size(); ++ i)
      |                     ~~^~~~~~~~~~
joi2019_ho_t2.cpp:53:17: warning: unused variable 'num' [-Wunused-variable]
   53 |             int num = *it, index = it - v.begin();
      |                 ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...