답안 #775995

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
775995 2023-07-07T08:13:33 Z vjudge1 Fountain (eJOI20_fountain) C++17
60 / 100
64 ms 6188 KB
#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define ll long long
#define pb push_back
#define N 2000005                                                                                
int main(){
	lalala;
	int n,q;cin>>n>>q;
	ll int arr[n][2],pre[n+2];
	pre[0]=0;
	pre[n+1]=1000000000000000000;
	for(int i=0;i<n;i++){
		cin>>arr[i][0]>>arr[i][1];
		pre[i+1]=arr[i][1]+pre[i];
	}
	if(q<=2000&&n<=1000){
		while(q--){
			ll int x,y;cin>>x>>y;
			x--;
			ll int cev=-1,cur=arr[x][0]-1;
			for(int i=x;i<n;i++){
				if(arr[i][0]<=cur)continue;
				cur=arr[i][0];
				//cout<<y<<" "<<arr[i][1]<<" "<<i<<endl;
				if(arr[i][1]<y){
					y-=arr[i][1];continue;
				}
				cev=i;
				break;
			}
			cout<<cev+1<<endl;
		}return 0;
	}

	while(q--){
		ll int x,y;cin>>x>>y;
		ll int eksi=pre[x-1];
		int l=x,r=n+1;
		while(l<r){
			int m=(l+r)/2;
			ll int deg=pre[m]-eksi;
			if(deg>=y){
				r=m;
			}
			else l=m+1;
		}
		if(l==n+1)l=0;
		cout<<l<<endl;
	}


}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 59 ms 4220 KB Output is correct
2 Correct 64 ms 6188 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 59 ms 4220 KB Output is correct
9 Correct 64 ms 6188 KB Output is correct
10 Incorrect 1 ms 372 KB Output isn't correct
11 Halted 0 ms 0 KB -