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