제출 #798711

#제출 시각아이디문제언어결과실행 시간메모리
798711tlnk07Osumnjičeni (COCI21_osumnjiceni)C++17
0 / 110
1076 ms8456 KiB
#include<bits/stdc++.h> using namespace std; long long n, q, x, y; pair<int, int> a[200001]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; for(int i = 1; i <= n; ++i) cin >> a[i].first >> a[i].second; cin >> q; while(q--) { cin >> x >> y; vector<pair<int, int>> vec(a + x, a + y + 1); 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...