結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2021-10-20 20:23:26 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 33 ms / 5,000 ms |
| コード長 | 692 bytes |
| コンパイル時間 | 4,993 ms |
| コンパイル使用メモリ | 265,724 KB |
| 最終ジャッジ日時 | 2025-01-25 02:01:52 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 40 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001
int main(){
int N,C,V;
cin>>N>>C>>V;
vector<int> S(V),T(V),Y(V),M(V);
rep(i,V)cin>>S[i];
rep(i,V)cin>>T[i];
rep(i,V)cin>>Y[i];
rep(i,V)cin>>M[i];
mcf_graph<int,int> G(N*(C+1));
rep(i,V){
rep(j,C+1){
if(j + Y[i] <= C)G.add_edge((S[i]-1)*(C+1) + j, (T[i]-1)*(C+1) + j + Y[i], 1, M[i]);
}
}
rep(j,C){
G.add_edge(j,j+1,1,0);
}
auto ret = G.flow(0,(N-1)*(C+1)+C, 1);
int ans = ret.second;
if(ret.first==0)ans = -1;
cout<<ans<<endl;
return 0;
}
沙耶花