結果

問題 No.1077 Noelちゃんと星々4
ユーザー imoni_kawaiiimoni_kawaii
提出日時 2020-06-12 23:57:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 931 bytes
コンパイル時間 2,123 ms
コンパイル使用メモリ 199,240 KB
実行使用メモリ 43,428 KB
最終ジャッジ日時 2023-09-06 11:30:18
合計ジャッジ時間 3,497 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
43,264 KB
testcase_01 AC 14 ms
43,168 KB
testcase_02 WA -
testcase_03 AC 27 ms
43,156 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 20 ms
43,196 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 16 ms
43,292 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 13 ms
43,224 KB
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#ifdef _DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif
#define REP(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
template<class T, class U> inline bool chmax(T &a, const U &b) { if(a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if(a > b) { a = b; return true; } return false; }

int n, y[1000], dp[1010][10100];

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  cin >> n;
  rep(i, n) cin >> y[i];
  rep(i, 1010) rep(j, 10100) dp[i][j] = (1<<30);
  dp[0][0] = 0;
  REP(i, 1, n+1) {
    int mn = (1<<30);
    rep(j, 10001) {
      chmin(mn, dp[i-1][j]);
      dp[i][j] = mn+abs(y[i]-j);
    }
  }
  int ans = (1<<30);
  rep(j, 10100) chmin(ans, dp[n-1][j]);
  cout << ans << '\n';
  return 0;
}
0