結果

問題 No.1077 Noelちゃんと星々4
ユーザー bachoppibachoppi
提出日時 2020-06-13 11:03:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 33 ms / 2,000 ms
コード長 981 bytes
コンパイル時間 1,015 ms
コンパイル使用メモリ 94,528 KB
実行使用メモリ 43,480 KB
最終ジャッジ日時 2023-09-07 04:09:45
合計ジャッジ時間 2,727 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
43,400 KB
testcase_01 AC 21 ms
43,164 KB
testcase_02 AC 29 ms
43,224 KB
testcase_03 AC 32 ms
43,160 KB
testcase_04 AC 23 ms
43,260 KB
testcase_05 AC 24 ms
43,404 KB
testcase_06 AC 25 ms
43,200 KB
testcase_07 AC 25 ms
43,172 KB
testcase_08 AC 25 ms
43,168 KB
testcase_09 AC 23 ms
43,388 KB
testcase_10 AC 32 ms
43,220 KB
testcase_11 AC 27 ms
43,208 KB
testcase_12 AC 27 ms
43,164 KB
testcase_13 AC 23 ms
43,340 KB
testcase_14 AC 31 ms
43,212 KB
testcase_15 AC 26 ms
43,388 KB
testcase_16 AC 24 ms
43,480 KB
testcase_17 AC 28 ms
43,168 KB
testcase_18 AC 32 ms
43,212 KB
testcase_19 AC 22 ms
43,200 KB
testcase_20 AC 20 ms
43,204 KB
testcase_21 AC 33 ms
43,404 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
次のファイルから読み込み:  /usr/local/gcc7/include/c++/12.2.0/string:50,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/bits/locale_classes.h:40,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/bits/ios_base.h:41,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/ios:42,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/ostream:38,
         次から読み込み:  /usr/local/gcc7/include/c++/12.2.0/iostream:39,
         次から読み込み:  main.cpp:1:
関数 ‘constexpr const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = int]’ 内,
    inlined from ‘int main()’ at main.cpp:51:14:
/usr/local/gcc7/include/c++/12.2.0/bits/stl_algobase.h:235:15: 警告: iteration 10101 invokes undefined behavior [-Waggressive-loop-optimizations]
  235 |       if (__b < __a)
      |           ~~~~^~~~~
main.cpp: 関数 ‘int main()’ 内:
main.cpp:18:43: 備考: within this loop
   18 | #define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
      |                                           ^
main.cpp:19:18: 備考: in expansion of macro ‘REP’
   19 | #define rep(i,n) REP(i,0,n)
      |                  ^~~
main.cpp:50:3: 備考: 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;
}
      
0