結果
問題 | No.1077 Noelちゃんと星々4 |
ユーザー |
|
提出日時 | 2024-10-08 23:46:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 11 ms / 2,000 ms |
コード長 | 472 bytes |
コンパイル時間 | 1,884 ms |
コンパイル使用メモリ | 194,400 KB |
最終ジャッジ日時 | 2025-02-24 17:07:34 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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;}