結果

問題 No.1077 Noelちゃんと星々4
ユーザー imoni_kawaiiimoni_kawaii
提出日時 2020-06-16 22:04:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 1,028 bytes
コンパイル時間 2,088 ms
コンパイル使用メモリ 200,000 KB
実行使用メモリ 43,496 KB
最終ジャッジ日時 2023-09-16 11:10:29
合計ジャッジ時間 3,466 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
43,436 KB
testcase_01 AC 12 ms
43,264 KB
testcase_02 AC 21 ms
43,280 KB
testcase_03 AC 24 ms
43,156 KB
testcase_04 AC 16 ms
43,496 KB
testcase_05 AC 15 ms
43,164 KB
testcase_06 AC 17 ms
43,224 KB
testcase_07 AC 18 ms
43,240 KB
testcase_08 AC 17 ms
43,300 KB
testcase_09 AC 16 ms
43,156 KB
testcase_10 AC 24 ms
43,168 KB
testcase_11 AC 20 ms
43,364 KB
testcase_12 AC 19 ms
43,224 KB
testcase_13 AC 15 ms
43,368 KB
testcase_14 AC 23 ms
43,276 KB
testcase_15 AC 19 ms
43,212 KB
testcase_16 AC 17 ms
43,164 KB
testcase_17 AC 20 ms
43,168 KB
testcase_18 AC 24 ms
43,164 KB
testcase_19 AC 15 ms
43,156 KB
testcase_20 AC 13 ms
43,160 KB
testcase_21 AC 25 ms
43,156 KB
権限があれば一括ダウンロードができます

ソースコード

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>;
const int INF = 1<<30; const ll LINF = 1LL<<60; const ld PI = 3.1415926535897932;
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 dp[1010][10100];

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