# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
242282 | 2020-06-27T08:05:49 Z | dantoh000 | 3단 점프 (JOI19_jumps) | C++14 | 570 ms | 124796 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n; int a[5005]; int st[5005][14]; ll dp[5005][5005]; int q; int query(int s, int e){ int d = e-s+1; int bt = 31-__builtin_clz(d); int ret = max(st[s][bt],st[e-(1<<bt)+1][bt]); //printf("max from %d to %d is %d\n",s,e,ret); return ret; } int main(){ scanf("%d",&n); for (int i = 0; i < n; i++){ scanf("%d",&a[i]); st[i][0] = a[i]; } for (int k = 1; k < 14; k++){ for (int i = 0; i+(1<<(k-1)) < n; i++){ st[i][k] = max(st[i][k-1],st[i+(1<<(k-1))][k-1]); } } for (int i = 0; i < n; i++){ for (int j = i+2; j < n; j++){ int mid = (i+j)/2; dp[i][j]= 0ll+a[i]+a[j]+query(i+1,mid); //printf("<%d,%d>: %d\n",i,j,query(i+1,mid)); } } for (int L = 2; L < n; L++){ for (int i = 0; i+L < n; i++){ int j = i+L; if (i){ dp[i-1][j] = max(dp[i-1][j], dp[i][j]); } if (j+1 < n){ dp[i][j+1] = max(dp[i][j+1],dp[i][j]); } } } scanf("%d",&q); for (int i = 0; i < q; i++){ int l,r; scanf("%d%d",&l,&r); --l, --r; printf("%lld\n",dp[l][r]); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 768 KB | Output is correct |
3 | Correct | 5 ms | 768 KB | Output is correct |
4 | Correct | 5 ms | 768 KB | Output is correct |
5 | Correct | 5 ms | 768 KB | Output is correct |
6 | Correct | 5 ms | 768 KB | Output is correct |
7 | Correct | 5 ms | 768 KB | Output is correct |
8 | Correct | 5 ms | 768 KB | Output is correct |
9 | Correct | 5 ms | 768 KB | Output is correct |
10 | Correct | 5 ms | 768 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 768 KB | Output is correct |
3 | Correct | 5 ms | 768 KB | Output is correct |
4 | Correct | 5 ms | 768 KB | Output is correct |
5 | Correct | 5 ms | 768 KB | Output is correct |
6 | Correct | 5 ms | 768 KB | Output is correct |
7 | Correct | 5 ms | 768 KB | Output is correct |
8 | Correct | 5 ms | 768 KB | Output is correct |
9 | Correct | 5 ms | 768 KB | Output is correct |
10 | Correct | 5 ms | 768 KB | Output is correct |
11 | Correct | 570 ms | 124608 KB | Output is correct |
12 | Correct | 530 ms | 124796 KB | Output is correct |
13 | Correct | 519 ms | 124664 KB | Output is correct |
14 | Correct | 518 ms | 124664 KB | Output is correct |
15 | Correct | 512 ms | 124536 KB | Output is correct |
16 | Correct | 533 ms | 123896 KB | Output is correct |
17 | Correct | 517 ms | 124032 KB | Output is correct |
18 | Correct | 525 ms | 124044 KB | Output is correct |
19 | Correct | 521 ms | 124508 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Runtime error | 18 ms | 1280 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 768 KB | Output is correct |
3 | Correct | 5 ms | 768 KB | Output is correct |
4 | Correct | 5 ms | 768 KB | Output is correct |
5 | Correct | 5 ms | 768 KB | Output is correct |
6 | Correct | 5 ms | 768 KB | Output is correct |
7 | Correct | 5 ms | 768 KB | Output is correct |
8 | Correct | 5 ms | 768 KB | Output is correct |
9 | Correct | 5 ms | 768 KB | Output is correct |
10 | Correct | 5 ms | 768 KB | Output is correct |
11 | Correct | 570 ms | 124608 KB | Output is correct |
12 | Correct | 530 ms | 124796 KB | Output is correct |
13 | Correct | 519 ms | 124664 KB | Output is correct |
14 | Correct | 518 ms | 124664 KB | Output is correct |
15 | Correct | 512 ms | 124536 KB | Output is correct |
16 | Correct | 533 ms | 123896 KB | Output is correct |
17 | Correct | 517 ms | 124032 KB | Output is correct |
18 | Correct | 525 ms | 124044 KB | Output is correct |
19 | Correct | 521 ms | 124508 KB | Output is correct |
20 | Runtime error | 18 ms | 1280 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
21 | Halted | 0 ms | 0 KB | - |