結果

問題 No.1077 Noelちゃんと星々4
ユーザー SEELSEEL
提出日時 2020-06-14 19:08:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 1,408 bytes
コンパイル時間 2,139 ms
コンパイル使用メモリ 202,348 KB
実行使用メモリ 81,380 KB
最終ジャッジ日時 2023-09-10 00:00:51
合計ジャッジ時間 4,115 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 3 ms
4,504 KB
testcase_02 AC 52 ms
56,604 KB
testcase_03 AC 66 ms
72,856 KB
testcase_04 AC 21 ms
23,948 KB
testcase_05 AC 16 ms
18,684 KB
testcase_06 AC 26 ms
30,352 KB
testcase_07 AC 30 ms
34,768 KB
testcase_08 AC 22 ms
25,748 KB
testcase_09 AC 19 ms
22,708 KB
testcase_10 AC 66 ms
72,736 KB
testcase_11 AC 43 ms
48,188 KB
testcase_12 AC 35 ms
39,976 KB
testcase_13 AC 16 ms
18,148 KB
testcase_14 AC 65 ms
71,148 KB
testcase_15 AC 35 ms
38,944 KB
testcase_16 AC 22 ms
26,592 KB
testcase_17 AC 39 ms
43,696 KB
testcase_18 AC 66 ms
74,128 KB
testcase_19 AC 14 ms
17,244 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 75 ms
81,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ld long double
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

void print(Vl vec){
    rep(i, 0, sz(vec)){
        if(i) cout << " ";
        cout << vec[i];
    }
    coel;
}

////////////////////////////////////////////////////////

// デバッグを消し忘れるな!!!

const ll mx = 10005;

int main() {
    ll n; cin >> n;
    Vl y(n+1);
    Rep(i, 1, n) cin >> y[i];

    vector<Vl> dp(n+1, Vl(mx, INF));
    rep(i, 0, mx){
        dp[1][i] = llabs(i-y[1]);
    }
    Rep(i, 2, n){
        ll M = INF;
        rep(j, 0, mx){
            chmin(M, dp[i-1][j]);
            chmin(dp[i][j], M + llabs(y[i] - j));
        }
    }
    ll ans = INF;
    rep(i, 0, mx){
        chmin(ans, dp[n][i]);
    }

    co(ans);

    return 0;
}
0