Submission #1313530

#TimeUsernameProblemLanguageResultExecution timeMemory
1313530cubedInspections (NOI23_inspections)C++20
29 / 100
1348 ms1114112 KiB
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define f first
// #define s second
#define pb(x) push_back(x)
#define int long long
 
const int MOD = 1e9+7;
const int inf = 1e9;
const int INF = 1e18+20;
const int LOG = 25;

void solve() {
    int n, m, q;
    cin>>n>>m>>q;
    
    vector<int> a;
    for (int i=0; i<m; i++) {
        int l, r;
        cin>>l>>r;
        l--; r--;

        for (int i=l; i<=r; i++) a.pb(i);
    }


    vector<int> last(n, -1);
    vector<int> gaps;

    int curr=0;
    for (auto i : a) {
        if (last[i]!=-1) {
            int gap = curr - last[i];
            //if (gap>s) cnt++;
            gaps.pb(gap);
        }

        last[i]=curr;
        curr++;
    }

    sort(gaps.begin(), gaps.end());

    while (q--) {
        int s;
        cin>>s;

        // how many elements in gaps where i > s
        int cnt = gaps.end() - upper_bound(gaps.begin(), gaps.end(), s);

        cout<<cnt<<" ";
    }
}

/*
n and m are less than 2000
gap>s

for each i, store the max and min gap of it.
*/

bool multi=false;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
  
    int t=1;
    if (multi) cin>>t;
 
    while (t--) solve();
 
    return 0;
}
#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...