結果
問題 | No.484 収穫 |
ユーザー | kyawashell |
提出日時 | 2018-04-16 14:14:28 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 89 ms / 3,000 ms |
コード長 | 1,328 bytes |
コンパイル時間 | 2,852 ms |
コンパイル使用メモリ | 199,852 KB |
実行使用メモリ | 97,244 KB |
最終ジャッジ日時 | 2023-09-09 10:52:26 |
合計ジャッジ時間 | 4,364 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,380 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 1 ms
4,376 KB |
testcase_07 | AC | 1 ms
4,376 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 3 ms
11,896 KB |
testcase_10 | AC | 4 ms
11,840 KB |
testcase_11 | AC | 4 ms
11,852 KB |
testcase_12 | AC | 74 ms
83,004 KB |
testcase_13 | AC | 74 ms
83,564 KB |
testcase_14 | AC | 76 ms
83,564 KB |
testcase_15 | AC | 89 ms
83,508 KB |
testcase_16 | AC | 65 ms
97,040 KB |
testcase_17 | AC | 62 ms
97,036 KB |
testcase_18 | AC | 61 ms
97,064 KB |
testcase_19 | AC | 62 ms
97,136 KB |
testcase_20 | AC | 62 ms
97,048 KB |
testcase_21 | AC | 62 ms
97,044 KB |
testcase_22 | AC | 61 ms
97,244 KB |
testcase_23 | AC | 61 ms
97,040 KB |
ソースコード
#include<bits/stdc++.h> typedef long long ll; typedef unsigned long long ull; using namespace std; #define pb push_back int dy[]={0, 0, 1, -1, 1, 1, -1, -1}; int dx[]={1, -1, 0, 0, 1, -1, -1, 1}; #define FOR(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--) #define mp make_pair #define fi first #define sc second ll INF = 1e12; ll dp[3000][3000][2]; ll n,a[3000]; int main(){ cin >> n; REP(i,n) { cin >> a[i]; REP(j,n) { dp[i][j][0] = dp[i][j][1] = INF; } } dp[0][n - 1][true] = a[n - 1]; dp[0][n - 1][false] = a[0]; RFOR(k,1,n) { for(int i = 0;i + k < n;i++) { int j = i + k; dp[i + 1][j][false] = min(dp[i + 1][j][false],max(dp[i][j][false] + 1,a[i + 1])); dp[i + 1][j][true] = min(dp[i + 1][j][true],max(dp[i][j][false] + j - i,a[j])); dp[i][j - 1][false] = min(dp[i][j - 1][false],max(dp[i][j][true] + j - i,a[i])); dp[i][j - 1][true] = min(dp[i][j - 1][true],max(dp[i][j][true] + 1,a[j - 1])); } } /*RFOR(k,1,n) { REP(i,k + 1) { int j = k - 1; if(i > j) continue; cout << dp[i][j][true] << " " << dp[i][j][false] << " "; } cout << endl; }*/ ll ans = INF; REP(i,n) { ans = min(ans,dp[i][i][true]); } cout << ans << endl; return 0; }