結果
問題 | No.1077 Noelちゃんと星々4 |
ユーザー |
![]() |
提出日時 | 2020-06-12 21:38:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 591 bytes |
コンパイル時間 | 734 ms |
コンパイル使用メモリ | 90,504 KB |
最終ジャッジ日時 | 2025-01-11 02:20:04 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#include <iostream>#include <vector>#include <string>#include <algorithm>#include <cstdio>#include <cstring>#include <cmath>using namespace std;using ll = long long;int main() {int n;cin >> n;int dp[10001] = {};for (int i = 0; i < n; i++) {int y;cin >> y;int t = 1 << 30;for (int j = 0; j <= 10000; j++) {t = min(t, dp[j]);dp[j] = t + abs(j - y);}}int r = 1 << 30;for (int j = 0; j <= 10000; j++) {r = min(r, dp[j]);}cout << r << endl;return 0;}