Submission #657301

# Submission time Handle Problem Language Result Execution time Memory
657301 2022-11-09T13:09:46 Z Banan Fountain (eJOI20_fountain) C++17
0 / 100
65 ms 3260 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int long long
#define double long double
#define endl '\n'
#define sz(a) (int)a.size()
#define pb push_back
#define fs first
#define sc second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
int const INF = LONG_LONG_MAX;

int n, q, d[200005], c[200005];

void solve()
{
    cin>>n>>q;
    for(int i=1;i<=n;i++)
    {
        cin>>d[i]>>c[i];
    }
    vector<int> pref(n+5, 0);
    for(int i=1;i<=n;i++)
    {
        pref[i]=pref[i-1]+c[i];
    }
    d[n+1]=INF;
    c[n+1]=INF;
    pref[n+1]=INF;
    while(q--)
    {
        int r, v;
        cin>>r>>v;
        int lo=r, hi=n+1, mid=(lo+hi)/2, ans;
        while(lo<=hi)
        {
            if(pref[mid]-pref[r-1]>v){hi=mid-1;mid=(lo+hi)/2;}
            else{ans=mid;lo=mid+1;mid=(lo+hi)/2;}
        }
        if(ans>n){cout<<0<<endl;}else{cout<<ans<<endl;}
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int tc=1;
    //cin>>tc;
    while(tc--)
    {
        solve();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 65 ms 3260 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -