40952023-03-14 11:49:171478Gladiátorok (40 pont)cpp17Accepted 40/40324ms6296 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    //ifstream cin("in.txt");
    int n;
    cin >> n;
    int q;
    cin >> q;

    vector<pair<int, int>> szen(n + 1);
    for(int i = 1; i <= n; i++){
        cin >> szen[i].first >> szen[i].second;
    }
    sort(szen.begin(), szen.end());
    /*for(int i = 1; i <= n; i++){
        cout << szen[i].first << " " << szen[i].second << '\n';
    }
    cout << '\n';*/
    vector<int> hps(n + 1);
    hps[1] = szen[1].first;
    int m = szen[1].second;
    for(int i = 2; i <= n; i++){
        hps[i] = max(hps[i - 1], szen[i].first - m);
        m += szen[i].second;
    }
    /*for(int i = 1; i <= n; i++){
        cout << hps[i] << " ";
    }*/
    while(q--){
        int a;
        cin >> a;
        cout << upper_bound(hps.begin(), hps.end(), a) - hps.begin() - 1 << " ";
    }



    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1816 KiB
2Accepted0/076ms2756 KiB
3Accepted2/23ms2276 KiB
4Accepted2/23ms2484 KiB
5Accepted2/28ms2860 KiB
6Accepted2/28ms2820 KiB
7Accepted2/28ms3068 KiB
8Accepted2/28ms3024 KiB
9Accepted2/29ms3284 KiB
10Accepted2/28ms3236 KiB
11Accepted2/232ms3612 KiB
12Accepted2/2165ms5620 KiB
13Accepted2/2229ms4384 KiB
14Accepted2/2247ms5880 KiB
15Accepted2/2321ms5836 KiB
16Accepted2/2250ms5832 KiB
17Accepted2/2246ms5836 KiB
18Accepted2/2303ms5964 KiB
19Accepted2/2202ms6176 KiB
20Accepted2/2202ms6296 KiB
21Accepted2/2275ms6236 KiB
22Accepted2/2324ms6148 KiB