結果
| 問題 | No.1 道のショートカット |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2026-10-14 21:31:50 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 2 ms / 5,000 ms |
| + 243µs | |
| コード長 | 847 bytes |
| 記録 | |
| コンパイル時間 | 2,692 ms |
| コンパイル使用メモリ | 347,128 KB |
| 実行使用メモリ | 9,900 KB |
| 最終ジャッジ日時 | 2026-10-14 21:31:59 |
| 合計ジャッジ時間 | 4,387 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 42 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n,c,v;cin>>n>>c>>v;
vector dp(n+1,vector<ll>(c+1,1LL<<60));
vector<ll>S(v),T(v),Y(v),M(v);
for(auto&o:S)cin>>o;
for(auto&o:T)cin>>o;
for(auto&o:Y)cin>>o;
for(auto&o:M)cin>>o;
vector<vector<array<ll,3>>>g(n+1);
for(int i=0;i<v;i++)
{
g[S[i]].push_back({T[i],Y[i],M[i]});
}
dp[1][0]=0;
for(int i=1;i<=n;i++)
{
for(auto[t,y,m]:g[i])
{
for(int j=0;j<=c;j++)
{
if(j+y>c)continue;
dp[t][j+y]=min(dp[t][j+y],dp[i][j]+m);
}
}
}
ll ans=1LL<<60;
for(int i=0;i<=c;i++)if(dp[n][i]!=1LL<<60)ans=min(ans,dp[n][i]);
cout<<(ans==1LL<<60?-1ll:ans)<<endl;
}