40412023-03-09 17:15:23gortomiGladiátorok (40 pont)cpp17Accepted 40/4070ms8500 KiB
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<pair<int, int> > a(n), c(q);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i].first >> a[i].second;
    }
    sort(a.begin(), a.end());
    vector<int> ans(q);
    for(int i = 0; i < q; i++)
    {
        cin >> c[i].first;
        c[i].second = i;
    }
    sort(c.begin(), c.end());
    int k = 0, sum = 0;
    for(auto x : c)
    {
        int v = x.first, ind = x.second;
        v += sum;
        while(k < n && a[k].first <= v)
        {
            v += a[k].second;
            sum += a[k].second;
            k++;
        }
        ans[ind] = k;
    }
    for(auto x : ans) cout << x << " ";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1828 KiB
2Accepted0/017ms2836 KiB
3Accepted2/23ms2244 KiB
4Accepted2/23ms2456 KiB
5Accepted2/24ms2736 KiB
6Accepted2/24ms2948 KiB
7Accepted2/24ms3156 KiB
8Accepted2/24ms3448 KiB
9Accepted2/24ms3488 KiB
10Accepted2/24ms3772 KiB
11Accepted2/212ms4348 KiB
12Accepted2/252ms6672 KiB
13Accepted2/250ms7356 KiB
14Accepted2/270ms8244 KiB
15Accepted2/268ms8240 KiB
16Accepted2/270ms8244 KiB
17Accepted2/270ms8236 KiB
18Accepted2/264ms8236 KiB
19Accepted2/264ms8172 KiB
20Accepted2/264ms8392 KiB
21Accepted2/265ms8500 KiB
22Accepted2/265ms8456 KiB