結果

問題 No.484 収穫
ユーザー tubo28tubo28
提出日時 2017-02-11 00:07:12
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,897 bytes
コンパイル時間 1,474 ms
コンパイル使用メモリ 169,496 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-28 10:23:37
合計ジャッジ時間 2,616 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
template<typename T> void __dump__(const T &first){ std::cerr << first << std::endl; }
template<typename First, typename... Rest>
void __dump__(const First& first, const Rest&... rest) { std::cerr << first << ", "; __dump__(rest...); }
#define dump(...) { std::cerr << __LINE__ << ":\t" #__VA_ARGS__ " = "; __dump__(__VA_ARGS__); }

#define int ll

int n;
vector<int> a;

const int INF = 1e18;
int opt[20][1<<20];

int dp(){
    rep(i, 20) rep(j, 1 << 20) opt[i][j] = INF;
    rep(i, 20) opt[i][1<<i] = a[i];
    rep(S, 1<<n) {
        rep(j, n) if(S >> j & 1){
            rep(k, n) if(~S >> k & 1){
                opt[k][S|1<<k] = min(opt[k][S|1<<k], max(opt[j][S] + abs(k - j), a[k]));
            }
        }
    }
    int ans = INF;
    rep(i, n) ans = min(ans, opt[i][(1<<n) - 1]);
    return ans;
}

int greedy(){
    int ans = INF;
    rep(_, 2){
        FOR(i, 1, n){
            int time = a[0];
            int j = 1;
            while(j < i){
                time = max(time + 1, a[j]);
                ++j;
            }
            j = n - 1;
            time = max(time + (n - 1) - j, a[j]);
            while(j >= i){
                time = max(time + 1, a[j]);
                --j;
            }
            ans = min(ans, time);
        }
        reverse(all(a));
    }
    return ans;
}

signed main(){
    while(cin >> n){
        a.resize(n);
        rep(i, n) cin >> a[i];
        // if(n < 20){
        //     cout << dp() << endl;
        // } else {
        cout << greedy() << endl;
        // }
    }
}
0