結果
| 問題 |
No.1077 Noelちゃんと星々4
|
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2020-06-14 01:20:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 50 ms / 2,000 ms |
| コード長 | 679 bytes |
| コンパイル時間 | 728 ms |
| コンパイル使用メモリ | 83,016 KB |
| 実行使用メモリ | 42,368 KB |
| 最終ジャッジ日時 | 2024-06-26 04:29:24 |
| 合計ジャッジ時間 | 2,099 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int N;
int Y[1000];
int dp[1001][10001];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
cin >> N;
for(int i = 0; i < N; i++) cin >> Y[i];
for(int i = 0; i < N; i++){
for(int j = 0; j <= 10000; j++){
dp[i+1][j] = dp[i][j]+abs(Y[i]-j);
if(j > 0) dp[i+1][j] = min(dp[i+1][j], dp[i+1][j-1]);
}
}
int ans = 1e9;
for(int i = 0; i <= 10000; i++) ans = min(ans, dp[N][i]);
cout << ans << endl;
}
milanis48663220