Submission #798714

#TimeUsernameProblemLanguageResultExecution timeMemory
798714tlnk07Osumnjičeni (COCI21_osumnjiceni)C++17
0 / 110
1066 ms2724 KiB
#include<bits/stdc++.h> using namespace std; long long n, q, x, y; vector<pair<int, int>> vec; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; for(int i = 1; i <= n; ++i) { cin >> x >> y; vec.push_back({x, y}); } cin >> q; while(q--) { cin >> x >> y; vec.push_back({INT_MAX, INT_MAX}); sort(vec.begin(), vec.end()); long long cnt = 0; pair<int, int> t; while(vec.size() > 1) { t = vec[0]; vec.erase(vec.begin() + 0); while(t.first != INT_MAX) { int l = 0, r = vec.size() - 1; while(l < r) { long long mid = (l + r) / 2; if(vec[mid].first <= t.second) l = mid + 1; else r = mid; } if(vec[l].first == INT_MAX || vec[l].first <= t.second) break; t = vec[l]; vec.erase(vec.begin() + l); } ++cnt; } cout << cnt << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...