結果

問題 No.705 ゴミ拾い Hard
ユーザー beetbeet
提出日時 2018-06-15 23:54:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 935 bytes
コンパイル時間 1,486 ms
コンパイル使用メモリ 169,596 KB
実行使用メモリ 12,708 KB
最終ジャッジ日時 2023-09-13 05:31:41
合計ジャッジ時間 21,555 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 4 ms
4,380 KB
testcase_15 AC 5 ms
4,376 KB
testcase_16 AC 5 ms
4,380 KB
testcase_17 AC 4 ms
4,376 KB
testcase_18 AC 4 ms
4,376 KB
testcase_19 AC 4 ms
4,380 KB
testcase_20 AC 4 ms
4,380 KB
testcase_21 AC 4 ms
4,380 KB
testcase_22 AC 5 ms
4,376 KB
testcase_23 AC 4 ms
4,380 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 954 ms
12,284 KB
testcase_34 AC 953 ms
12,600 KB
testcase_35 AC 996 ms
12,540 KB
testcase_36 AC 1,019 ms
12,536 KB
testcase_37 AC 989 ms
12,524 KB
testcase_38 AC 1,031 ms
12,220 KB
testcase_39 AC 1,049 ms
12,516 KB
testcase_40 AC 1 ms
4,380 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 2 ms
4,380 KB
testcase_43 AC 1,082 ms
12,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n),x(n),y(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  for(Int i=0;i<n;i++) cin>>x[i];
  for(Int i=0;i<n;i++) cin>>y[i];

  auto tri=[](Int x){x=abs(x);return x*x*x;};
  
  const Int INF = 1e18;
  vector<Int> dp(n+1,INF);
  random_device rd;
  mt19937 mt(rd());
  
  dp[0]=0;
  for(Int i=0;i<n;i++){
    for(Int j=0;j<=min<Int>(i,400);j++){
      Int k=i-j;
      chmin(dp[i+1],dp[k]+tri(x[k]-a[i])+tri(y[k]));
      k=j;
      chmin(dp[i+1],dp[k]+tri(x[k]-a[i])+tri(y[k]));
    }
    for(Int j=0;j<=min<Int>(i,50);j++){
      int k=mt()%(i+1);
      chmin(dp[i+1],dp[k]+tri(x[k]-a[i])+tri(y[k]));
    }
  }
  cout<<dp[n]<<endl;
  return 0;
}

0