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, cnt = 0;
pair<int, int> a[200001];
bool check[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;
sort(a + 1, a + n + 1);
cin >> q;
while(q--)
{
cin >> x >> y;
for(int i = x; i <= y; ++i)
{
if(check[i]) continue;
pair<int, int> temp = a[i];
for(int j = i + 1; j <= y; ++j)
{
if(a[j].first > temp.second)
{
temp = a[j];
check[j] = true;
}
}
++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... |