結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
leafirby
|
| 提出日時 | 2020-05-26 21:41:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,712 bytes |
| コンパイル時間 | 1,479 ms |
| コンパイル使用メモリ | 180,480 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-08 05:26:29 |
| 合計ジャッジ時間 | 2,450 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 16 WA * 24 |
ソースコード
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 9999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(50) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 998244353
#define MAX 10000000
#define ALL(a) a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
lli A,B,C,D,E,F,K,N,M,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
cin >> N >> K >> M;
DV(dp,lli,N,K+10,INF);//dp[i][j]:頂点iにお金をj円持ってる状態で行くのにかかる最小時間
DV(G,pint,N,N,pint(INF,INF));//G[i][j]:頂点iと頂点jを結ぶ辺のコスト(金,時間)
DV(temp,lli,4,M,0);
rep(i,0,4)rep(j,0,M)cin >> temp[i][j];
rep(i,0,M)G[temp[0][i]-1][temp[1][i]-1]=pint(temp[2][i],temp[3][i]);
dp[0][K]=0;
rep(i,0,N)rep(j,0,K+10)rep(k,i+1,N)if(j-G[i][k].first>=0)chmin(dp[k][j-G[i][k].first],dp[i][j]+G[i][k].second);
num=INF;
rep(i,0,K+10)chmin(num,dp[N-1][i]);
if(num==INF)num=-1;
Out(num);
}
leafirby