61352023-11-03 00:30:33horvathabelGladiátorok (40 pont)cpp17Accepted 40/40328ms10792 KiB
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
bool r(pair<ll,ll> a, pair<ll,ll> b){
    if (a.first==b.first) return(a.second>b.second);
    return (a.first<b.first);
}
int main()
{
    int n,m;
    cin>>n>>m;
    vector<pair<ll,ll>> s;
    vector<ll> b;
    for (int i=0; i<n;i++){
        int a,b;
        cin>>a>>b;
        s.push_back({a,b});
    }
    sort(s.begin(),s.end(),r);
    int kv=s[0].second;
    vector<ll> p={s[0].first};
    for (int i=1;i<n;i++){
        p.push_back(max(s[i].first-kv,p[i-1]));
        kv+=s[i].second;
    }
    int ans;
    for (int i=0;i<m;i++){
        ll x;
        cin>>x;
        x++;
        cout<<lower_bound(p.begin(),p.end(),x)-p.begin()<<" ";
    }


}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1688 KiB
2Accepted0/068ms3744 KiB
3Accepted2/23ms2072 KiB
4Accepted2/23ms2316 KiB
5Accepted2/28ms2872 KiB
6Accepted2/212ms2940 KiB
7Accepted2/28ms3184 KiB
8Accepted2/28ms3372 KiB
9Accepted2/213ms3380 KiB
10Accepted2/29ms3380 KiB
11Accepted2/241ms4644 KiB
12Accepted2/2223ms10200 KiB
13Accepted2/2209ms6844 KiB
14Accepted2/2323ms10584 KiB
15Accepted2/2328ms10536 KiB
16Accepted2/2261ms10536 KiB
17Accepted2/2259ms10540 KiB
18Accepted2/2221ms10540 KiB
19Accepted2/2232ms10792 KiB
20Accepted2/2312ms10756 KiB
21Accepted2/2323ms10748 KiB
22Accepted2/2291ms10752 KiB