제출 #1123026

#제출 시각아이디문제언어결과실행 시간메모리
1123026ezzzayFountain (eJOI20_fountain)C++20
30 / 100
270 ms2856 KiB
#include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back const int N=3e5+5; int a[N]; bool vis[N]; int d[N],c[N]; vector<int>ans ; int ps[N]; signed main(){ int n,q; cin>>n>>q; for(int i=1;i<=n;i++){ cin>>d[i]>>c[i]; } for(int i=1;i<=n;i++){ ps[i]=ps[i-1]+c[i]; } ps[n+1]=ps[n]; for(int i=0;i<q;i++){ int idx,v; cin>>idx>>v; int hi=n,lo=idx; while(hi>=lo){ int mid=(hi+lo)/2; if(ps[mid]-ps[idx-1]<v){ lo=mid+1; } else{ hi=mid-1; } } if(lo==n+1)lo=0; ans.pb(lo); } for(auto a:ans)cout<<a<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...