結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
hirokazu1020
|
| 提出日時 | 2015-04-21 19:12:50 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 926 bytes |
| コンパイル時間 | 490 ms |
| コンパイル使用メモリ | 81,324 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-08 03:51:07 |
| 合計ジャッジ時間 | 1,462 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 8 WA * 32 |
ソースコード
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())
#define indexOf(v,x) (find(all(v),x)-v.begin())
int s[1500],t[1500],y[1500],m[1500];
int dp[301][50];
int main(){
int n,c,v;
cin>>n>>c>>v;
rep(i,v)cin>>s[i],s[i]--;
rep(i,v)cin>>t[i],t[i]--;
rep(i,v)cin>>y[i];
rep(i,v)cin>>m[i];
fill(dp[0],dp[301],INF);
dp[0][0]=0;
int ans=-1;
rep(i,c)rep(j,n){
int d=dp[i][j];
rep(k,n){
if(j==s[k]&&i+y[k]<=c&&d+m[k]<dp[i+y[k]][t[k]]){
dp[i+y[k]][t[k]]=d+m[k];
if(t[k]==n-1&&(ans==-1||d+m[k]<ans))ans=d+m[k];
}
}
}
cout<<ans<<endl;
return 0;
}
hirokazu1020