結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
nablaenergy_21
|
| 提出日時 | 2015-04-25 16:09:50 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 5,000 ms |
| コード長 | 847 bytes |
| コンパイル時間 | 119 ms |
| コンパイル使用メモリ | 23,552 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-20 16:12:28 |
| 合計ジャッジ時間 | 1,295 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 40 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
28 | scanf("%d %d %d",&N,&C,&V);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
main.cpp:30:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
30 | scanf("%d",&S[i]);
| ~~~~~^~~~~~~~~~~~
main.cpp:33:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
33 | scanf("%d",&T[i]);
| ~~~~~^~~~~~~~~~~~
main.cpp:36:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
36 | scanf("%d",&Y[i]);
| ~~~~~^~~~~~~~~~~~
main.cpp:39:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
39 | scanf("%d",&M[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <stdio.h>
int memo[50][301],done[50][301];
int N,C,V,S[1500],T[1500],Y[1500],M[1500];
int min(int a,int b){
if(a>b){return b;}else{return a;}
}
int dp(int a,int b){
int i,an;
if(done[a][b]==1){return memo[a][b];}
an = 100000000;
for(i=0;i<=V;i++){
if(S[i] == a+1 && b-Y[i]>=0){
an = min(an, M[i]+dp(T[i]-1,b-Y[i]));
}
}
memo[a][b] = an;
done[a][b] = 1;
return memo[a][b];
}
int main(void){
int i,j;
scanf("%d %d %d",&N,&C,&V);
for(i=0;i<V;i++){
scanf("%d",&S[i]);
}
for(i=0;i<V;i++){
scanf("%d",&T[i]);
}
for(i=0;i<V;i++){
scanf("%d",&Y[i]);
}
for(i=0;i<V;i++){
scanf("%d",&M[i]);
}
for(i=0;i<N;i++){
for(j=0;j<=C;j++){
done[i][j] = 0;
}
}
for(i=0;i<=C;i++){
done[N-1][i] = 1;
memo[N-1][i] = 0;
}
if(dp(0,C)<100000000){
printf("%d\n",dp(0,C));
}else{
printf("-1\n");
}
}
nablaenergy_21