| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 242282 | dantoh000 | Triple Jump (JOI19_jumps) | C++14 | 570 ms | 124796 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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]);
}
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
