結果

問題 No.1 道のショートカット
コンテスト
ユーザー id-ord
提出日時 2026-01-09 14:17:29
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
結果
WA  
実行時間 -
コード長 631 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,668 ms
コンパイル使用メモリ 167,024 KB
実行使用メモリ 7,852 KB
最終ジャッジ日時 2026-01-09 14:17:34
合計ジャッジ時間 4,357 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 4
other WA * 28 RE * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
int fastest[50][301];
struct SYM{int S;int Y;int M;};
std::vector<SYM> in[50];
int main(){
	int N,C,V;
	std::cin>>N>>C>>V;
	while(V--){
		SYM sym;int T;std::cin>>sym.S>>T>>sym.Y>>sym.M;
		sym.S--;
		in[T-1].push_back(sym);
	}
	for (int i=0;i<N;i++) {
		for (int j=0;j<=C;j++) {
			fastest[i][j]=200000;
		}
	}
	fastest[0][C]=0;
	for (int i = 1; i < N; i++) {
		for(auto e:in[i]){
			for(int j=0;j+e.Y<=C;j++)
				if(fastest[i][j+e.Y]>fastest[e.S][j]+e.M)fastest[i][j+e.Y]=fastest[e.S][j]+e.M;
		}
	}
	int min=200000;
	for(auto m:fastest[N-1])if(min>m)min=m;
	std::cout<<(min==200000?-1:min);
}
0