結果
問題 | No.1077 Noelちゃんと星々4 |
ユーザー |
|
提出日時 | 2020-06-16 00:54:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 81 ms / 2,000 ms |
コード長 | 614 bytes |
コンパイル時間 | 1,874 ms |
コンパイル使用メモリ | 197,624 KB |
最終ジャッジ日時 | 2025-01-11 04:33:37 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#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;}