Submission #1097966

# Submission time Handle Problem Language Result Execution time Memory
1097966 2024-10-08T17:04:58 Z VMaksimoski008 Inspections (NOI23_inspections) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
#define ar array
#define int long long

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;

vector<pll> qus;

int bin_search(ll p) {
    int l=0, r=qus.size()-1, ans=-1;
    while(l <= r) {
        int mid = (l + r) / 2;
        if(qus[mid].first <= p) ans = mid, l = mid + 1;
        else r = mid - 1;
    }
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cout.tie(0); cin.tie(0);

    int n, m, q; cin >> n >> m >> q;
    ll day = 1;

    vector<int> L(m), R(m);
    for(int i=0; i<m; i++) cin >> L[i] >> R[i];

    for(int i=0; i<q; i++) {
        ll x; cin >> x;
        qus.push_back({ x, i });
    }

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

    vector<ll> ans(q), last(n+1);

    for(int i=0; i<m; i++) {
        for(int j=L[i]; j<=R[i]; j++) {
            if(last[j]) {
                int p = bin_search(day - last[j] - 1);
                if(p > -1) ans[p]++;
            }
            last[j] = day++;
        }
    }

    for(int i=q-2; i>=0; i--) ans[i] += ans[i+1];
    sort(ans.rbegin(), ans.rend());
    for(auto x : ans) cout << x << " ";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -