結果

問題 No.1077 Noelちゃんと星々4
ユーザー kcz146kcz146
提出日時 2020-06-16 00:54:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 614 bytes
コンパイル時間 1,957 ms
コンパイル使用メモリ 204,676 KB
実行使用メモリ 81,516 KB
最終ジャッジ日時 2023-09-16 10:45:03
合計ジャッジ時間 3,803 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 51 ms
56,684 KB
testcase_03 AC 66 ms
72,684 KB
testcase_04 AC 21 ms
23,848 KB
testcase_05 AC 16 ms
19,004 KB
testcase_06 AC 26 ms
30,240 KB
testcase_07 AC 30 ms
34,452 KB
testcase_08 AC 23 ms
26,068 KB
testcase_09 AC 20 ms
22,520 KB
testcase_10 AC 67 ms
72,692 KB
testcase_11 AC 44 ms
48,380 KB
testcase_12 AC 36 ms
40,004 KB
testcase_13 AC 16 ms
18,028 KB
testcase_14 AC 65 ms
71,144 KB
testcase_15 AC 35 ms
39,144 KB
testcase_16 AC 24 ms
26,600 KB
testcase_17 AC 39 ms
43,856 KB
testcase_18 AC 69 ms
74,004 KB
testcase_19 AC 15 ms
17,236 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 75 ms
81,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

using namespace std;
using ll = long long int;
using lc = complex<double>;

int main(void) {
    constexpr ll MOD = 1e9 + 7;
    constexpr double PI = acos(-1);
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    ll n;
    cin >> n;
    vector<vector<ll>> dp(n+1, vector<ll>(1e4+1));
    for(ll i=0; i<n; i++) {
        ll y;
        cin >> y;
        dp[i+1][0] = dp[i][0] + abs(y);
        for(ll j=1; j<=1e4; j++)
            dp[i+1][j] = min(dp[i+1][j-1], dp[i][j] + abs(y-j));
    }
    cout << *min_element(dp[n].begin(), dp[n].end()) << endl;
}
0