#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
4 ms |
344 KB |
Output is correct |
6 |
Correct |
5 ms |
348 KB |
Output is correct |
7 |
Correct |
3 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1540 ms |
6488 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
3 ms |
348 KB |
Output is correct |
5 |
Correct |
4 ms |
344 KB |
Output is correct |
6 |
Correct |
5 ms |
348 KB |
Output is correct |
7 |
Correct |
3 ms |
348 KB |
Output is correct |
8 |
Execution timed out |
1540 ms |
6488 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |