45032023-03-29 11:05:31Error42Gladiátorok (40 pont)cpp17Accepted 40/40354ms8924 KiB
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

using ll = long long;

struct glad {
    ll pow, inc;

    bool operator <(glad const& rhs) const {
        return pow < rhs.pow;
    }
};

int main() {
    int n, q;
    cin >> n >> q;

    vector<glad> g(n);

    for (auto& c : g)
        cin >> c.pow >> c.inc;

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

    ll inc = 0;

    for (auto& c : g) {
        c.pow -= inc;
        inc += c.inc;
    }

    vector<ll> req(n);

    req[0] = g[0].pow;

    for (int i = 1; i < n; i++)
        req[i] = max(req[i - 1], g[i].pow);

    for (int i = 0; i < q; i++) {
        int p;
        cin >> p;

        cout << upper_bound(req.begin(), req.end(), p) - req.begin() << " ";
    }

    cout << "\n";
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1812 KiB
2Accepted0/046ms3404 KiB
3Accepted2/23ms2276 KiB
4Accepted2/23ms2484 KiB
5Accepted2/28ms2708 KiB
6Accepted2/28ms2680 KiB
7Accepted2/28ms2936 KiB
8Accepted2/28ms3236 KiB
9Accepted2/213ms3276 KiB
10Accepted2/29ms3448 KiB
11Accepted2/245ms4040 KiB
12Accepted2/2165ms8064 KiB
13Accepted2/2201ms5724 KiB
14Accepted2/2354ms8188 KiB
15Accepted2/2250ms8144 KiB
16Accepted2/2340ms8144 KiB
17Accepted2/2344ms8144 KiB
18Accepted2/2204ms8408 KiB
19Accepted2/2330ms8352 KiB
20Accepted2/2312ms8612 KiB
21Accepted2/2217ms8924 KiB
22Accepted2/2259ms8880 KiB