結果
問題 | No.484 収穫 |
ユーザー | ei1333333 |
提出日時 | 2017-02-07 09:22:17 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 962 bytes |
コンパイル時間 | 1,591 ms |
コンパイル使用メモリ | 144,968 KB |
実行使用メモリ | 66,328 KB |
最終ジャッジ日時 | 2023-08-25 22:36:53 |
合計ジャッジ時間 | 2,973 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 20 ms
66,100 KB |
testcase_01 | AC | 21 ms
66,088 KB |
testcase_02 | AC | 20 ms
66,032 KB |
testcase_03 | AC | 21 ms
66,100 KB |
testcase_04 | AC | 20 ms
66,112 KB |
testcase_05 | AC | 21 ms
66,248 KB |
testcase_06 | WA | - |
testcase_07 | AC | 21 ms
66,032 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 41 ms
66,116 KB |
testcase_13 | AC | 41 ms
66,112 KB |
testcase_14 | AC | 41 ms
66,044 KB |
testcase_15 | AC | 41 ms
66,124 KB |
testcase_16 | AC | 41 ms
66,180 KB |
testcase_17 | AC | 41 ms
66,100 KB |
testcase_18 | AC | 40 ms
66,116 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 41 ms
66,180 KB |
testcase_23 | AC | 41 ms
66,092 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; typedef long long int64; inline void chmin(int64 &a, int64 b) { a = min(a, b); } inline void chmax(int64 &a, int64 b) { a = max(a, b); } const int64 INF = 1LL << 55; int N, A[2003]; int64 dp[2003][2003][2]; int main() { cin >> N; for(int i = 1; i <= N; i++) { cin >> A[i]; } fill_n(**dp, 2003 * 2003 * 2, INF); dp[2][N][0] = A[1]; dp[1][N - 1][1] = A[N]; for(int i = N - 2; i >= 0; i--) { for(int j = 1; j + i <= N; j++) { const int L = j, R = j + i; chmin(dp[L + 1][R][0], dp[L][R][0] + 1); chmin(dp[L + 1][R][0], dp[L][R][1] + j + 1); chmax(dp[L + 1][R][0], A[L]); chmin(dp[L][R - 1][1], dp[L][R][0] + j + 1); chmin(dp[L][R - 1][1], dp[L][R][1] + 1); chmax(dp[L][R - 1][1], A[R]); } } int64 ret = INF; for(int i = 1; i <= N + 1; i++) { chmin(ret, dp[i][i - 1][0]); chmin(ret, dp[i][i - 1][1]); } cout << ret << endl; }