# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
219531 | 2020-04-05T13:35:26 Z | MKopchev | 3단 점프 (JOI19_jumps) | C++14 | 4000 ms | 33896 KB |
#include<bits/stdc++.h> using namespace std; const int nmax=(1<<19)+42,MX=20; int n,q; int inp[nmax]; vector< pair<int,int> > start; pair<int,int> table[20][nmax]; int mem[nmax]; pair<int/*value*/,int/*id*/> take_mx(int l,int r) { int st=mem[r-l+1]; return max(table[st][l],table[st][r-(1<<st)+1]); } int query() { int l,r; scanf("%i%i",&l,&r); int ret=0; for(auto k:start) { int a=k.first; int b=k.second; if(l<=a&&b+b-a<=r) { ret=max(ret,inp[a]+inp[b]+take_mx(b+b-a,r).first); } } return ret; } stack<int> active; int main() { scanf("%i",&n); for(int i=1;i<=n;i++)scanf("%i",&inp[i]); for(int i=1;i<=n;i++) table[0][i]={inp[i],i}; for(int st=1;(1<<st)<=n;st++) for(int i=1;i+(1<<st)-1<=n;i++) table[st][i]=max(table[st-1][i],table[st-1][i+(1<<(st-1))]); for(int i=1;i<=n;i++) { while((1<<(mem[i]+1))<=i)mem[i]++; } for(int i=1;i<=n;i++) { while(active.size()&&inp[active.top()]<=inp[i]) { start.push_back({active.top(),i}); active.pop(); } if(active.size())start.push_back({active.top(),i}); active.push(i); } scanf("%i",&q); for(int i=1;i<=q;i++) printf("%i\n",query()); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Execution timed out | 4070 ms | 4984 KB | Time limit exceeded |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 74 ms | 33640 KB | Output is correct |
2 | Correct | 60 ms | 31468 KB | Output is correct |
3 | Correct | 61 ms | 31980 KB | Output is correct |
4 | Correct | 73 ms | 33512 KB | Output is correct |
5 | Correct | 73 ms | 33512 KB | Output is correct |
6 | Correct | 66 ms | 33512 KB | Output is correct |
7 | Correct | 65 ms | 33384 KB | Output is correct |
8 | Correct | 65 ms | 33388 KB | Output is correct |
9 | Correct | 70 ms | 33896 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 5 ms | 384 KB | Output is correct |
5 | Correct | 5 ms | 384 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 384 KB | Output is correct |
9 | Correct | 5 ms | 384 KB | Output is correct |
10 | Correct | 5 ms | 384 KB | Output is correct |
11 | Execution timed out | 4070 ms | 4984 KB | Time limit exceeded |
12 | Halted | 0 ms | 0 KB | - |