結果
| 問題 | No.704 ゴミ拾い Medium | 
| コンテスト | |
| ユーザー |  ikd | 
| 提出日時 | 2018-07-02 13:58:38 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 547 bytes | 
| コンパイル時間 | 793 ms | 
| コンパイル使用メモリ | 72,872 KB | 
| 実行使用メモリ | 14,880 KB | 
| 最終ジャッジ日時 | 2024-07-01 01:29:25 | 
| 合計ジャッジ時間 | 6,723 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 20 TLE * 1 -- * 23 | 
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
void chmin(int &l, int r){if(l>r)l=r;}
int main(){
  int n; cin>> n;
  vector<int> a(n+1);
  rep(i, n) cin>> a[i+1];
  vector<int> x(n+1);
  rep(i, n) cin>> x[i+1];
  vector<int> y(n+1);
  rep(i, n) cin>> y[i+1];
  const int inf=1e8;
  vector<int> dp(n+1, inf);
  dp[0]=0;
  for(int i=1; i<=n; i++){
    for(int j=1; j<=i; j++){
      chmin(dp[i], dp[j-1]+y[j]+abs(x[j]-a[i]));
    }
  }
  cout<< dp[n]<< endl;
  return 0;
}
            
            
            
        