結果

問題 No.484 収穫
ユーザー あっちむいてホイ!あっちむいてホイ!
提出日時 2021-09-27 16:07:27
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,443 bytes
コンパイル時間 1,275 ms
コンパイル使用メモリ 99,896 KB
実行使用メモリ 97,276 KB
最終ジャッジ日時 2023-09-20 16:48:29
合計ジャッジ時間 38,546 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
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 OLE -
testcase_18 WA -
testcase_19 WA -
testcase_20 TLE -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <utility>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
using namespace std;
using ll = long long int;
#define chmax(x,y)  (x) = ((x) > (y)) ? (x) : ((x) = (y));
#define chmin(x,y)  (x) = ((x) < (y)) ? (x) : ((x) = (y));
const int INF = 1e9;
const ll INFL = 1e18;
const int Mod = 1e9 + 7;
const int dx[] = {0,1,0,-1};
const int dy[] = {1,0,-1,0};


int main(int argc, char const *argv[])
{
  int N; cin >> N;
  vector<ll> A(N); for(auto &a : A)cin >> a;
  vector<vector<vector<ll>>> dp(2,vector<vector<ll>>(N+1,vector<ll>(N+1,INFL)));
  dp[0][1][N] = A[0];
  dp[1][0][N-1] = A[N-1];
  for(int len = N;len > 0;--len)
  {
    for(int i=0;i<N;++i)
    {
      if(i+len > N)continue;
      if(i > 0)
      {
        chmin(dp[0][i+1][i+len],max(dp[0][i][i+len]+1,A[i]));
        chmin(dp[1][i][i+len-1],max(dp[0][i][i+len]+len,A[i+len-1]));
//        std::cout << dp[0][i+1][i+len] << " " << i+1 << " " << i+len << std::endl;
        std::cout << dp[1][i][i+len-1] << std::endl;
      }

      if(i+len < N)
      {
        chmin(dp[1][i][i+len-1],max(dp[1][i][i+len]+1,A[i+len-1]));
        chmin(dp[0][i+1][i+len],max(dp[1][i][i+len]+len,A[i]));
      }
    }
  }
  ll answer = INFL;
  for(int i=0;i<N;++i)
  {
    chmin(answer,min(dp[0][i][i], dp[1][i][i]));
  }
  std::cout << answer << std::endl;
}
0