結果
問題 | No.1247 ブロック登り |
ユーザー | 沙耶花 |
提出日時 | 2020-10-02 23:39:52 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,657 ms / 3,000 ms |
コード長 | 1,121 bytes |
コンパイル時間 | 2,204 ms |
コンパイル使用メモリ | 209,668 KB |
実行使用メモリ | 227,064 KB |
最終ジャッジ日時 | 2023-09-25 00:01:24 |
合計ジャッジ時間 | 26,577 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 191 ms
226,600 KB |
testcase_01 | AC | 189 ms
226,604 KB |
testcase_02 | AC | 189 ms
226,660 KB |
testcase_03 | AC | 193 ms
226,592 KB |
testcase_04 | AC | 190 ms
226,608 KB |
testcase_05 | AC | 190 ms
226,780 KB |
testcase_06 | AC | 189 ms
226,704 KB |
testcase_07 | AC | 196 ms
226,596 KB |
testcase_08 | AC | 196 ms
226,768 KB |
testcase_09 | AC | 191 ms
226,656 KB |
testcase_10 | AC | 191 ms
226,776 KB |
testcase_11 | AC | 1,650 ms
227,004 KB |
testcase_12 | AC | 1,578 ms
226,864 KB |
testcase_13 | AC | 1,647 ms
227,064 KB |
testcase_14 | AC | 1,657 ms
226,852 KB |
testcase_15 | AC | 1,581 ms
227,040 KB |
testcase_16 | AC | 1,615 ms
226,904 KB |
testcase_17 | AC | 1,573 ms
226,896 KB |
testcase_18 | AC | 1,480 ms
227,060 KB |
testcase_19 | AC | 353 ms
226,596 KB |
testcase_20 | AC | 252 ms
226,776 KB |
testcase_21 | AC | 212 ms
226,600 KB |
testcase_22 | AC | 203 ms
226,596 KB |
testcase_23 | AC | 199 ms
226,592 KB |
testcase_24 | AC | 192 ms
226,972 KB |
testcase_25 | AC | 1,646 ms
227,060 KB |
testcase_26 | AC | 1,643 ms
226,868 KB |
testcase_27 | AC | 1,642 ms
226,908 KB |
testcase_28 | AC | 1,625 ms
227,036 KB |
ソースコード
#include <stdio.h> #include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000300 int N,K; vector<int> A; int get(int l,int r,int isL,int now){ if(l<0||r>=N)return -Inf; if(now>K)return -Inf; static vector dp(301,vector(301,vector(2,vector(301,-Inf)))); if(dp[l][r][isL][now]!=-Inf)return dp[l][r][isL][now]; int ret = -Inf+1; if(l==r){ if(now==K)ret = now * A[l]; else ret = -Inf; } else{ if(isL){ ret = max(ret,get(l+1,r,isL,now+1) + A[l] * now); } else{ ret = max(ret,get(l,r-1,isL,now+1) + A[r]*now); } ret = max(ret,get(l,r,isL,now+2)); ret = max(ret,get(l,r,isL^1,now+(r-l))); } dp[l][r][isL][now] = ret; return ret; } int main(){ cin>>N>>K; A.resize(N); rep(i,N)cin>>A[i]; vector<int> ans(N,-Inf); for(int i=0;i<N;i++){ for(int j=i;j<N;j++){ for(int k=0;k<=K;k++){ int t = get(i,j,0,k); if(j-k>=i)ans[j-k] = max(ans[j-k],t); t = get(i,j,1,k); if(i+k<=j)ans[i+k] = max(ans[i+k],t); } } } //cout<<get(2,4,0,0)<<endl; rep(i,N){ cout<<ans[i]<<endl; } return 0; }