結果
問題 | No.1077 Noelちゃんと星々4 |
ユーザー | bachoppi |
提出日時 | 2020-06-13 11:03:39 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 34 ms / 2,000 ms |
コード長 | 981 bytes |
コンパイル時間 | 883 ms |
コンパイル使用メモリ | 95,904 KB |
実行使用メモリ | 43,392 KB |
最終ジャッジ日時 | 2024-06-24 22:45:25 |
合計ジャッジ時間 | 2,131 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 21 ms
43,264 KB |
testcase_01 | AC | 21 ms
43,264 KB |
testcase_02 | AC | 29 ms
43,264 KB |
testcase_03 | AC | 31 ms
43,264 KB |
testcase_04 | AC | 24 ms
43,364 KB |
testcase_05 | AC | 22 ms
43,264 KB |
testcase_06 | AC | 23 ms
43,264 KB |
testcase_07 | AC | 25 ms
43,264 KB |
testcase_08 | AC | 24 ms
43,392 KB |
testcase_09 | AC | 22 ms
43,284 KB |
testcase_10 | AC | 31 ms
43,136 KB |
testcase_11 | AC | 27 ms
43,356 KB |
testcase_12 | AC | 25 ms
43,264 KB |
testcase_13 | AC | 23 ms
43,264 KB |
testcase_14 | AC | 31 ms
43,264 KB |
testcase_15 | AC | 26 ms
43,264 KB |
testcase_16 | AC | 24 ms
43,264 KB |
testcase_17 | AC | 27 ms
43,304 KB |
testcase_18 | AC | 31 ms
43,264 KB |
testcase_19 | AC | 22 ms
43,392 KB |
testcase_20 | AC | 21 ms
43,264 KB |
testcase_21 | AC | 34 ms
43,392 KB |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/string:50, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/locale_classes.h:40, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/ios_base.h:41, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ios:42, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ostream:38, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/iostream:39, from main.cpp:1: In function 'constexpr const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = int]', inlined from 'int main()' at main.cpp:51:14: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/bits/stl_algobase.h:235:15: warning: iteration 10101 invokes undefined behavior [-Waggressive-loop-optimizations] 235 | if (__b < __a) | ~~~~^~~~~ main.cpp: In function 'int main()': main.cpp:18:43: note: within this loop 18 | #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) | ^ main.cpp:19:18: note: in expansion of macro 'REP' 19 | #define rep(i,n) REP(i,0,n) | ^~~ main.cpp:50:3: note: in expansion of macro 'rep' 50 | rep(i, 101010){ | ^~~
ソースコード
#include<iostream> #include<string> #include<algorithm> #include<vector> #include<iomanip> #include<math.h> #include<complex> #include<queue> #include<deque> #include<stack> #include<map> #include<set> #include<bitset> #include<functional> #include<assert.h> #include<numeric> using namespace std; #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i ) #define rep(i,n) REP(i,0,n) using ll = long long; const int inf=1e9+7; const ll longinf=1LL<<60 ; const ll mod=998244353 ; #define pai 3.141592653589793238462643383279 int main(){ int N; cin >> N; int a[N]; rep(i, N){ cin >> a[i]; } int dp[1010][10101] = {}; int mi; rep(i, 1010){ rep(j, 10101){ if(i==0) dp[i][j]=0; else dp[i][j]=inf; } } rep(i, N){ int mi = inf; rep(j, 10100){ dp[i+1][j] = min(mi, dp[i][j]) + abs(j-a[i]); mi = min(mi, dp[i][j]); } } int ans=inf; rep(i, 101010){ ans = min(ans, dp[N][i]); } cout << ans << endl; }