제출 #974426

#제출 시각아이디문제언어결과실행 시간메모리
974426vjudge1Fountain (eJOI20_fountain)C++17
30 / 100
1540 ms6488 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...