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 <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
int main(){
int N, Q, M;
cin >> N >> M >> Q;
vector<vector<int>> arr(N);
int day = 0;
for(int i = 0; i < M; i ++){
int a, b;
cin >> a >> b;
for(int j = a-1; j < b; j ++){
arr[j].push_back(day++);
}
}
//for(int i : arr[2])cout << i << endl;
vector<pair<long long, long long>> pref;
map<long long, long long> vals;
for(int i = 0; i < N; i ++){
for(int j = 1; j < (int)arr[i].size(); j ++){
vals[arr[i][j] - arr[i][j-1] - 1]++;
}
}
for(auto[l, r]: vals){
pref.push_back({l,r});
}
pref.push_back({1e16,0});
for(int i = (int)pref.size()-2; i >= 0; i --){
pref[i].second += pref[i+1].second;
}
for(int i = 0; i < Q; i ++){
long long q;
cin >> q;
int c = 0;
c += (*lower_bound(pref.begin(), pref.end(), make_pair(q, 0ll))).second;
cout << c << " ";
}
cout << endl;
return 0;
}
# | 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... |