Submission #691014

# Submission time Handle Problem Language Result Execution time Memory
691014 2023-01-30T20:51:36 Z raul2008487 Fountain (eJOI20_fountain) C++17
30 / 100
326 ms 6292 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define vl vector<ll>
#define endl "\n"
#define INF 0x3F3F3F3F
using namespace std;
int main(){
    ll n,q,r,x,i;
    cin>>n>>q;
    vl d(n+1),c(n+1),pre(n+2);
    pre[0]=0;
    pre[n+1]=INF;
    for(i=1;i<=n;i++){
        cin>>d[i]>>c[i];
        pre[i]=pre[i-1]+c[i];
    }
    /*for(i=0;i<=n+1;i++){
        cout<<pre[i]<<' ';
    }
    cout<<endl;*/
    while(q--){
        cin>>r>>x;
        ll nw=x+pre[r-1];
        ll idx=upper_bound(pre.begin(),pre.end(),nw)-pre.begin();
        if(pre[idx-1]==nw){
            cout<<idx-1<<endl;
        }
        else if(idx==(n+1)){
            cout<<0<<endl;
        }
        else{
            cout<<idx<<endl;
        }
    }
}
/*
5 10
3 5
5 7
7 9
9 11
11 13
*/
# 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 Correct 296 ms 3348 KB Output is correct
2 Correct 326 ms 6292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -