#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll nx=2e5+5;
ll n, m, q, l, r, s, t, x;
vector<pair<ll, ll>> ins;
map<ll, pair<ll, ll>> mp;
void split(ll x)
{
if (!x) return;
auto itr=mp.lower_bound(x);
if (itr->first==x) return;
mp[x]={itr->second.first, itr->second.second-(itr->first-x)};
itr->second.first=x+1;
}
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
cin>>n>>m>>q;
mp[n]={1, -1e18};
for (int i=1; i<=m; i++)
{
cin>>l>>r;
split(l-1);
split(r);
for (auto itr=mp.lower_bound(l); itr!=mp.end()&&itr->first<=r; itr=mp.erase(itr))
{
ll sz=itr->first-itr->second.first+1;
t+=sz;
ins.push_back({t-itr->second.second, sz});
}
mp[r]={l, t};
}
sort(ins.begin(), ins.end());
for (int i=0; i<ins.size(); i++) if (ins[i].first>=1e18) ins[i].second=0;
for (int i=(int)ins.size()-2; i>=0; i--) ins[i].second+=ins[i+1].second;
for (int i=1; i<=q; i++)
{
cin>>x;
auto itr=upper_bound(ins.begin(), ins.end(), make_pair(x, LLONG_MAX));
cout<<itr->second<<' ';
}
}
| # | 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... |