結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
chiho_miyako
|
| 提出日時 | 2015-04-23 12:49:32 |
| 言語 | Java (openjdk 23) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 1,601 bytes |
| コンパイル時間 | 1,751 ms |
| コンパイル使用メモリ | 76,936 KB |
| 実行使用メモリ | 753,536 KB |
| 最終ジャッジ日時 | 2024-07-08 03:51:21 |
| 合計ジャッジ時間 | 10,889 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 4 MLE * 2 -- * 34 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner koko = new Scanner(System.in);
int n = koko.nextInt();
int c = koko.nextInt();
int v = koko.nextInt();
int[] s = new int[v];
int[] t = new int[v];
int[] y = new int[v];
int[] m = new int[v];
for(int i=0; i<v; i++){
s[i]=koko.nextInt();
}
for(int i=0; i<v; i++){
t[i]=koko.nextInt();
}
for(int i=0; i<v; i++){
y[i]=koko.nextInt();
}
for(int i=0; i<v; i++){
m[i]=koko.nextInt();
}
boolean[][][] stop = new boolean[n+1][c+1][49001];
stop[1][0][0]=true;
for(int i=2; i<n+1; i++){
for(int j=0; j<v; j++){
if(i==t[j]){
for(int cost=0; cost<c+1; cost++){
for(int time=0; time<49001; time++){
if(stop[s[j]][cost][time]&&cost+y[j]<c+1){
stop[i][cost+y[j]][time+m[j]]=true;
}
}
}
}
}
}
boolean flag = false;
loop1: for(int i=0; i<49001; i++){
for(int cost=0; cost<c+1; cost++){
if(stop[n][cost][i]){
System.out.println(i);
flag=true;
break loop1;
}
}
}
if(!flag){
System.out.println(-1);
}
}
}
chiho_miyako