# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
407204 | 2021-05-18T15:53:02 Z | victoriad | Fountain (eJOI20_fountain) | C++14 | 1500 ms | 3868 KB |
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include <utility> #include <queue> #include <map> #include <iomanip> #include <stack> #include <fstream> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); int n,q; cin>>n>>q; int vo,r,l; vector<long long int>v(n); vector<long long int>d(n); for(int i=0;i<n;i++){ cin>>d[i]>>v[i]; } vector<int>con(n); for(int i=0;i<n;i++){ bool b=false; for(int k=i;k<n;k++){ if(d[i]<d[k]){ con[i]=k; b=true; break; } } if(!b)con[i]=-1; } for(int i=0;i<q;i++){ cin>>r>>l; r--; l-=v[r]; if(l<=0)cout<<r+1<<"\n"; else{ int i=r; while(l>0 || i!=-1){ l-=v[con[i]]; if(con[i]==-1){ cout<<0<<"\n"; break; } if(l<=0){ cout<<con[i]+1<<"\n"; break; } i=con[i]; } if(i==-1)cout<<0<<"\n"; } } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 2 ms | 332 KB | Output is correct |
5 | Correct | 4 ms | 332 KB | Output is correct |
6 | Correct | 2 ms | 332 KB | Output is correct |
7 | Correct | 2 ms | 332 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1576 ms | 3868 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 332 KB | Output is correct |
3 | Correct | 1 ms | 332 KB | Output is correct |
4 | Correct | 2 ms | 332 KB | Output is correct |
5 | Correct | 4 ms | 332 KB | Output is correct |
6 | Correct | 2 ms | 332 KB | Output is correct |
7 | Correct | 2 ms | 332 KB | Output is correct |
8 | Execution timed out | 1576 ms | 3868 KB | Time limit exceeded |
9 | Halted | 0 ms | 0 KB | - |