This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |