이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,q;
cin>>n>>q;
pair<int,int> ps[n];
pair<int,pair<int,int>> pe[q];
int h[q]={0};
for(int i=0;i<n;i++)
{
cin>>ps[i].first>>ps[i].second;
}
for(int i=0;i<q;i++)
{
pe[i].first=0;
cin>>pe[i].second.first>>pe[i].second.second;
}
for(int i=0;i<q;i++)
{
int x=pe[i].first;
int y=pe[i].second.first;
int z=pe[i].second.second;
for(int j=y-1;j<n;j++)
{
if(x<ps[j].first)
{
if(z>ps[j].second)
{
z-=ps[j].second;
x=ps[j].first;
}
else
{
h[i]=j+1;
break;
}
}
else
{
continue;
}
}
cout<<h[i]<<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... |