結果

問題 No.1077 Noelちゃんと星々4
ユーザー bachoppi
提出日時 2020-06-13 11:03:39
言語 C++14
(gcc 13.3.0 + boost 1.87.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
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
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){
      |   ^~~

ソースコード

diff #
プレゼンテーションモードにする

#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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0