結果
問題 |
No.1077 Noelちゃんと星々4
|
ユーザー |
![]() |
提出日時 | 2020-06-12 21:26:29 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 1,290 bytes |
コンパイル時間 | 2,731 ms |
コンパイル使用メモリ | 193,468 KB |
最終ジャッジ日時 | 2025-01-11 02:10:18 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 20 |
ソースコード
#define ENABLE_DEBUG 1 // Kana's kitchen {{{ #include<bits/stdc++.h> #define ALL(v) std::begin(v),std::end(v) #define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++) using i32 = std::int_least32_t; using i64 = std::int_least64_t; using u32 = std::uint_least32_t; using u64 = std::uint_least64_t; using usize = std::size_t; template <class T, class U> using pair = std::pair<U, T>; template <class T> using diag_pair = std::pair<T, T>; template <class... Args> using tuple = std::tuple<Args...>; template <class T> using vec = std::vector<T>; template <class T> using numr = std::numeric_limits<T>; #ifdef NGTKANA #include<debug.hpp> #else #define DEBUG(...)(void)0 #endif /*}}}*/ auto cmn = [](auto& x, auto y){ if (x>y) { x=y; return true; } return false; }; int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::cout << std::setprecision(15) << std::fixed; i64 max = 10'000; i64 n; std::cin >> n; vec<i64> dp(max+1); while (n--) { i64 x; std::cin >> x; for (i64 i=0; i<=max; i++) { dp.at(i) += std::abs(i - x); } for (i64 i=1; i<=max; i++) { cmn(dp.at(i), dp.at(i-1)); } } std::cout << dp.at(max) << '\n'; }