結果

問題 No.1 道のショートカット
ユーザー 沙耶花沙耶花
提出日時 2021-10-20 20:23:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 5,000 ms
コード長 692 bytes
コンパイル時間 4,780 ms
コンパイル使用メモリ 278,568 KB
実行使用メモリ 26,120 KB
最終ジャッジ日時 2023-10-20 11:08:07
合計ジャッジ時間 7,306 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 24 ms
21,760 KB
testcase_09 AC 15 ms
12,028 KB
testcase_10 AC 9 ms
8,028 KB
testcase_11 AC 15 ms
12,036 KB
testcase_12 AC 30 ms
26,120 KB
testcase_13 AC 31 ms
25,396 KB
testcase_14 AC 4 ms
4,628 KB
testcase_15 AC 3 ms
4,348 KB
testcase_16 AC 6 ms
6,376 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 4 ms
4,628 KB
testcase_19 AC 6 ms
5,844 KB
testcase_20 AC 7 ms
6,640 KB
testcase_21 AC 8 ms
7,748 KB
testcase_22 AC 5 ms
5,580 KB
testcase_23 AC 27 ms
22,820 KB
testcase_24 AC 32 ms
25,652 KB
testcase_25 AC 12 ms
10,172 KB
testcase_26 AC 9 ms
8,016 KB
testcase_27 AC 25 ms
20,508 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 6 ms
5,864 KB
testcase_30 AC 3 ms
4,348 KB
testcase_31 AC 5 ms
5,328 KB
testcase_32 AC 19 ms
15,128 KB
testcase_33 AC 13 ms
11,232 KB
testcase_34 AC 23 ms
19,456 KB
testcase_35 AC 3 ms
4,348 KB
testcase_36 AC 6 ms
5,592 KB
testcase_37 AC 3 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 6 ms
5,844 KB
testcase_40 AC 3 ms
4,348 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 AC 2 ms
4,348 KB
testcase_43 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0