# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
878880 | AndreasK | Fountain (eJOI20_fountain) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,Q;
cin>>N>>Q;
int c;
pair <int,int> A[N];//diameter capacity
int ps[N];
for (c=0;c<N;c++){
cin>>A[c].first>>A[c].second;
if (c==0)
ps[c]=A[c].second;
else
ps[c]=ps[c-1]+A[c].second;
}
while (Q--){
int where,how_many;
cin>>where>>how_many;
where--;int mx=0;
int start=where;
int stop=N-1;
while (start<stop){
int mid=(start+stop)/2;
if (ps[mid]<how_many)
start=mid+1;
else
stopmid-1;
}
if (start!=N+1)
cout<<stop+1<<'\n';