結果
問題 |
No.1077 Noelちゃんと星々4
|
ユーザー |
|
提出日時 | 2024-10-08 23:45:52 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 470 bytes |
コンパイル時間 | 1,820 ms |
コンパイル使用メモリ | 194,788 KB |
最終ジャッジ日時 | 2025-02-24 17:07:26 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 1 RE * 19 |
ソースコード
#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(N+1,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; }