249842026-02-17 11:04:21KevinGladiátorok (40 pont)cpp17Accepted 40/4070ms4916 KiB
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pll=pair<ll, ll>;

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n, q; cin >> n >> q;
    vector<pll> ellenfel(n), hos(q);
    for (ll i=0; i<n; i++) cin >> ellenfel[i].first >> ellenfel[i].second;
    for (ll i=0; i<q; i++){
        cin >> hos[i].first;
        hos[i].second=i;
    }
    sort(ellenfel.begin(), ellenfel.end());
    sort(hos.begin(), hos.end());
    ll bonus=0;
    vector<ll> out(q, n);
    ll curr=0;
    for (ll i=0; i<n; i++){
        while (curr<q && hos[curr].first+bonus<ellenfel[i].first){
            out[hos[curr].second]=i;
            curr++;
        }
        bonus+=ellenfel[i].second;
    }
    for (ll& z:out) cout << z << ' ';
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/01ms316 KiB
2Accepted0/014ms1332 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/23ms316 KiB
6Accepted2/23ms316 KiB
7Accepted2/23ms516 KiB
8Accepted2/22ms316 KiB
9Accepted2/23ms316 KiB
10Accepted2/23ms316 KiB
11Accepted2/29ms1004 KiB
12Accepted2/252ms3380 KiB
13Accepted2/250ms3812 KiB
14Accepted2/270ms4852 KiB
15Accepted2/268ms4848 KiB
16Accepted2/270ms4660 KiB
17Accepted2/268ms4848 KiB
18Accepted2/261ms4916 KiB
19Accepted2/263ms4908 KiB
20Accepted2/264ms4916 KiB
21Accepted2/264ms4660 KiB
22Accepted2/264ms4660 KiB