結果

問題 No.484 収穫
ユーザー milanis48663220milanis48663220
提出日時 2020-06-20 17:16:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,357 bytes
コンパイル時間 688 ms
コンパイル使用メモリ 83,044 KB
実行使用メモリ 34,804 KB
最終ジャッジ日時 2023-09-16 17:38:38
合計ジャッジ時間 2,671 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,704 KB
testcase_01 AC 2 ms
5,632 KB
testcase_02 WA -
testcase_03 AC 2 ms
5,380 KB
testcase_04 AC 1 ms
5,388 KB
testcase_05 AC 2 ms
5,428 KB
testcase_06 AC 2 ms
5,520 KB
testcase_07 AC 2 ms
5,580 KB
testcase_08 AC 2 ms
5,664 KB
testcase_09 AC 3 ms
8,408 KB
testcase_10 AC 3 ms
8,408 KB
testcase_11 AC 3 ms
8,372 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 53 ms
34,688 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int N, A[2002];
int dp[2][2002][2002];

// dp[0][i][j] -> i-1にいて[i, j]が残っている
// dp[1][i][j] -> j+1にいて[i, j]が残っている

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < N; j++) {
            dp[0][i][j] = 1e5;
            dp[1][i][j] = 1e5;
        }
    }
    if(N == 1){
        cout << A[0] << endl;
        return 0;
    }
    dp[0][1][N-1] = A[0];
    dp[1][0][N-2] = A[N-1];
    for(int i = N-2; i >= 1; i--){
        for(int j = 0; i+j <= N-1; j++){
            int k = i+j;
            dp[0][j+1][k] = min(dp[0][j+1][k], max(dp[0][j][k]+1, A[j]));
            dp[1][j][k-1] = min(dp[1][j][k-1], max(dp[0][j][k]+k-(j-1), A[k]));
            dp[0][j+1][k] = min(dp[0][j+1][k], max(dp[1][j][k]+k+1-j, A[j]));
            dp[1][j][k-1] = min(dp[1][j][k-1], max(dp[1][j][k]+1, A[k]));
        }
    }
    int ans = 1e5;
    for(int i = 0; i < N; i++){
        ans = min(ans, max(dp[0][i][i]+1, A[i]));
        ans = min(ans, max(dp[1][i][i]+1, A[i]));
    }
    cout << ans << endl;
}
0