結果
| 問題 | No.1077 Noelちゃんと星々4 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-10-08 23:46:24 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 20 ms / 2,000 ms |
| コード長 | 472 bytes |
| 記録 | |
| コンパイル時間 | 1,015 ms |
| コンパイル使用メモリ | 214,128 KB |
| 実行使用メモリ | 9,192 KB |
| 最終ジャッジ日時 | 2026-07-05 22:12:40 |
| 合計ジャッジ時間 | 2,366 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll N;
cin>>N;
vector<ll> DP(10001,1e18);
DP[0]=0;
for(int i=0;i<N;i++){
ll Y;
cin>>Y;
ll M=1e18;
for(int j=0;j<=10000;j++){
M=min(M,DP[j]);
DP[j]=M+abs(j-Y);
}
}
ll an=1e18;
for(int i=0;i<10001;i++)an=min(an,DP[i]);
cout<<an<<endl;
}