Submission #1316829

#TimeUsernameProblemLanguageResultExecution timeMemory
1316829vaishakhvInspections (NOI23_inspections)C++20
29 / 100
145 ms159360 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
	ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    ll n, m, q, day = 0; cin >> n >> m >> q;
    vector<pair<ll,ll>> lr(m);
    vector<ll> last(n + 1, -1); 
    ll gaps[(ll)2e7];
    ll max_gaps_fn = 0; // for now :wilted_rose:

    for (ll i{}; i < m; i++){
        cin >> lr[i].first >> lr[i].second;
        ll li = lr[i].first, ri = lr[i].second;

        for (ll j = li; j <= ri; j++){
            ll prev = last[j];
            last[j] = day;
            day++;

            if (prev >= 0){ gaps[max_gaps_fn] = day-prev-2; max_gaps_fn++;}
        }
    }

    vector<ll> s(q);
    for (ll i{}; i < q; i++){
        cin >> s[i];
    }

    sort(gaps, gaps + max_gaps_fn);
    for (ll Q{}; Q < q; Q++){
        ll i = lower_bound(gaps, gaps + max_gaps_fn, s[Q]) - gaps;
        cout << max_gaps_fn - i << " ";
    }
}
#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...