# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
931437 | 2024-02-21T19:30:39 Z | kirakosyan | Fountain (eJOI20_fountain) | C++17 | 207 ms | 3276 KB |
#include<algorithm> #include<iostream> #include<vector> #include<string> #include<random> #include<cmath> #include<stack> #include<map> #include <iomanip> #include <queue> #include <set> using namespace std; using ll = long long; using ull = unsigned long long; vector<ll>v,vis; vector<vector<ll>>gp; void solve(){ ll n,q; cin >> n >> q; vector<ll>d(n),c(n),pref(n); for(ll i=0;i<n;i++)cin >> d[i] >> c[i]; pref[0]=c[0]; for(ll i=1;i<n;i++){ pref[i]=pref[i-1]+c[i]; } if(n<=1000&&q<=2000){ for(int i=0;i<q;i++){ int a,b,f=0,cnt=0,ans=0; cin >> a >> b; a--; for(int i=a;i<n;i++){ if(i!=a&&d[i]<=cnt)continue; if(b>c[i]){ b-=c[i]; cnt=d[i]; } else{ cout<<i+1<<endl; f=1; break; } } if(f==0)cout<<f<<endl; } } else{ for(ll i=0;i<q;i++){ ll a,b; cin >> a >> b; --a; if(a!=0){ a--; ll k=lower_bound(pref.begin(),pref.end(),pref[a]+b)-pref.begin(); if(k==n)cout<<0<<endl; else cout<<k+1<<endl; } else{ ll k=lower_bound(pref.begin(),pref.end(),b)-pref.begin(); if(k==n)cout<<0<<endl; else cout<<k+1<<endl; } } } } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin.tie(nullptr); // ll _; cin >> _; // while (_--){ solve(); // } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 2 ms | 348 KB | Output is correct |
4 | Correct | 2 ms | 348 KB | Output is correct |
5 | Correct | 3 ms | 348 KB | Output is correct |
6 | Correct | 4 ms | 348 KB | Output is correct |
7 | Correct | 3 ms | 348 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 181 ms | 3276 KB | Output is correct |
2 | Correct | 207 ms | 3156 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 1 ms | 348 KB | Output is correct |
3 | Correct | 2 ms | 348 KB | Output is correct |
4 | Correct | 2 ms | 348 KB | Output is correct |
5 | Correct | 3 ms | 348 KB | Output is correct |
6 | Correct | 4 ms | 348 KB | Output is correct |
7 | Correct | 3 ms | 348 KB | Output is correct |
8 | Correct | 181 ms | 3276 KB | Output is correct |
9 | Correct | 207 ms | 3156 KB | Output is correct |
10 | Incorrect | 3 ms | 344 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |