結果
問題 | No.1077 Noelちゃんと星々4 |
ユーザー | 👑 jupiro |
提出日時 | 2020-06-13 00:03:14 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 76 ms / 2,000 ms |
コード長 | 1,548 bytes |
コンパイル時間 | 1,295 ms |
コンパイル使用メモリ | 131,508 KB |
実行使用メモリ | 81,124 KB |
最終ジャッジ日時 | 2023-09-06 11:30:33 |
合計ジャッジ時間 | 2,801 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 52 ms
56,704 KB |
testcase_03 | AC | 69 ms
72,464 KB |
testcase_04 | AC | 21 ms
23,808 KB |
testcase_05 | AC | 17 ms
18,636 KB |
testcase_06 | AC | 28 ms
30,240 KB |
testcase_07 | AC | 32 ms
34,548 KB |
testcase_08 | AC | 24 ms
25,936 KB |
testcase_09 | AC | 21 ms
22,664 KB |
testcase_10 | AC | 66 ms
72,440 KB |
testcase_11 | AC | 43 ms
48,112 KB |
testcase_12 | AC | 37 ms
40,084 KB |
testcase_13 | AC | 15 ms
17,808 KB |
testcase_14 | AC | 65 ms
70,888 KB |
testcase_15 | AC | 35 ms
38,768 KB |
testcase_16 | AC | 23 ms
26,476 KB |
testcase_17 | AC | 39 ms
43,692 KB |
testcase_18 | AC | 71 ms
73,792 KB |
testcase_19 | AC | 15 ms
17,212 KB |
testcase_20 | AC | 2 ms
4,376 KB |
testcase_21 | AC | 76 ms
81,124 KB |
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内: main.cpp:49:79: 警告: ignoring return value of ‘std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&; size_type = long unsigned int]’, declared with attribute ‘nodiscard’ [-Wunused-result] 49 | vector<ll> y(n); for (int i = 0; i < n; i++) scanf("%lld", &y[i]), y[i]; | ^ 次のファイルから読み込み: /usr/local/gcc7/include/c++/12.2.0/vector:64, 次から読み込み: /usr/local/gcc7/include/c++/12.2.0/queue:61, 次から読み込み: main.cpp:8: /usr/local/gcc7/include/c++/12.2.0/bits/stl_vector.h:1121:7: 備考: ここで宣言されています 1121 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ^~~~~~~~
ソースコード
#include <cstdio> #include <iostream> #include <string> #include <sstream> #include <stack> #include <algorithm> #include <cmath> #include <queue> #include <map> #include <set> #include <cstdlib> #include <bitset> #include <tuple> #include <assert.h> #include <deque> #include <bitset> #include <iomanip> #include <limits> #include <chrono> #include <random> #include <array> #include <unordered_map> #include <functional> #include <complex> #include <numeric> template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } constexpr long long MAX = 5100000; constexpr long long INF = 1LL << 60; constexpr int inf = 1000000007; constexpr long long mod = 1000000007LL; //constexpr long long mod = 998244353LL; const long double PI = acos((long double)(-1)); using namespace std; typedef unsigned long long ull; typedef long long ll; typedef long double ld; int main() { /* cin.tie(nullptr); ios::sync_with_stdio(false); */ ll n; scanf("%lld", &n); const ll mx = 10000; vector<vector<ll>> dp(n, vector<ll>(mx + 1, INF)); vector<ll> y(n); for (int i = 0; i < n; i++) scanf("%lld", &y[i]), y[i]; for (int i = 0; i <= mx; i++) dp[0][i] = llabs(i - y[0]); for (int i = 1; i < n; i++) { ll mn = INF; for (int j = 0; j <= mx; j++) { chmin(mn, dp[i - 1][j]); chmin(dp[i][j], mn + llabs(y[i] - j)); } } ll res = INF; for (int i = 0; i <= mx; i++) chmin(res, dp[n - 1][i]); cout << res << endl; return 0; }