結果
| 問題 |
No.705 ゴミ拾い Hard
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2018-06-15 23:52:55 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 885 bytes |
| コンパイル時間 | 1,564 ms |
| コンパイル使用メモリ | 172,048 KB |
| 実行使用メモリ | 19,508 KB |
| 最終ジャッジ日時 | 2024-06-30 15:38:50 |
| 合計ジャッジ時間 | 5,552 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 20 TLE * 1 -- * 19 |
ソースコード
#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,300);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]));
k=mt()%(i+1);
chmin(dp[i+1],dp[k]+tri(x[k]-a[i])+tri(y[k]));
}
}
cout<<dp[n]<<endl;
return 0;
}
beet