이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/* :) */
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pll pair<ll, ll>
const int sz = 1e5+5;
pll a[sz];
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll n, q, v, r;
cin>>n>>q;
for (ll i = 1; i<=n; i++){
cin>>a[i].first>>a[i].second;
}
while (q--){
cin>>v>>r;
ll l = a[v].first, f = 1;
r -= a[v].second;
if (r <= 0){
cout<<v<<endl;
continue;
}
for (ll i = v+1; i<=n; i++){
if (a[i].first > l){
r -= a[i].second;
if (r <= 0){
cout<<i<<endl;
f = 0;
break;
}
l = a[i].first;
}
}
if (f) cout<<0<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |