結果

問題 No.484 収穫
ユーザー uenokuuenoku
提出日時 2017-02-12 09:20:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,712 bytes
コンパイル時間 920 ms
コンパイル使用メモリ 106,072 KB
実行使用メモリ 103,448 KB
最終ジャッジ日時 2023-08-28 14:50:34
合計ジャッジ時間 4,153 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,368 KB
testcase_01 WA -
testcase_02 AC 2 ms
5,372 KB
testcase_03 AC 2 ms
5,428 KB
testcase_04 AC 2 ms
5,392 KB
testcase_05 AC 2 ms
5,660 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 188 ms
102,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "math.h"
#include <algorithm>
#include <set>
#include <complex>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <unordered_map>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define ifor(i, a, b) for (int i = (a); i < (b); i++)
#define rfor(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
lli mod = 1000000007;
lli dp[2][2100][2100];
struct d {
    lli j, k;
};
int main()
{

    int n;
    cin >> n;
    lli a[2100];
    rep(i, n) cin >> a[i];

    vector<d> m;
    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            m.push_back({i, j});
        }
    }
    sort(m.begin(), m.end(), [](d l, d r) -> bool {
            return (l.k-l.j)>(r.k-r.j);
    });
    dp[0][1][n - 1] = a[0];
    dp[1][0][n - 2] = a[n - 1];
    {
        for (auto s : m) {
            int j = s.j;
            int k = s.k;
            //cout << j << ' ' << k << endl;
            if (j > k)
                continue;

            rep(i, 2)
            {
                if (i == 0) {
                    dp[1][j][k - 1] = max(dp[i][j][k] + k - j + 1, a[k]);
                    dp[0][j + 1][k] = max(dp[i][j][k] + 1, a[j]);
                } else if (i == 1) {
                    dp[1][j][k - 1] = max(dp[i][j][k] + 1, a[k]);
                    dp[0][j + 1][k] = max(dp[i][j][k] + k - j + 1, a[j]);
                }
            }
        }
    }
    lli ans = mod * mod;
    rep(i, n)
    {
        ans = min(ans, max(max(a[i], dp[0][i][i]), dp[1][i][i]));
    }
    cout << ans << endl;
}
0