이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;
const int MXN = 1e5 + 10 ;
int cap[MXN] = {0};
int di[MXN] = {0};
int pscap[MXN] = {0};
int main(){
//faster io
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//subtask 2
int N, Q;
cin>>N>>Q;
for(int i=1; i<=N; i++) cin>>di[i]>>cap[i];
for(int i=1; i<=N; i++) pscap[i] = pscap[i-1] + cap[i];
while(Q--){
int R, V;
cin>>R>>V;
int idx = lower_bound(pscap + R, pscap + N + 1, (V + pscap[R-1])) - (pscap);
if(idx>N) cout<<"0\n";
else cout<<idx<<"\n";
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |