結果

問題 No.2604 Initial Motion
ユーザー TairitsuMeowTairitsuMeow
提出日時 2024-01-12 22:58:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 152 ms / 3,000 ms
コード長 1,219 bytes
コンパイル時間 2,499 ms
コンパイル使用メモリ 191,732 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-12 22:58:24
合計ジャッジ時間 5,695 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 5 ms
6,676 KB
testcase_04 AC 6 ms
6,676 KB
testcase_05 AC 5 ms
6,676 KB
testcase_06 AC 6 ms
6,676 KB
testcase_07 AC 5 ms
6,676 KB
testcase_08 AC 5 ms
6,676 KB
testcase_09 AC 5 ms
6,676 KB
testcase_10 AC 6 ms
6,676 KB
testcase_11 AC 6 ms
6,676 KB
testcase_12 AC 5 ms
6,676 KB
testcase_13 AC 96 ms
6,676 KB
testcase_14 AC 73 ms
6,676 KB
testcase_15 AC 39 ms
6,676 KB
testcase_16 AC 86 ms
6,676 KB
testcase_17 AC 115 ms
6,676 KB
testcase_18 AC 109 ms
6,676 KB
testcase_19 AC 106 ms
6,676 KB
testcase_20 AC 87 ms
6,676 KB
testcase_21 AC 72 ms
6,676 KB
testcase_22 AC 104 ms
6,676 KB
testcase_23 AC 83 ms
6,676 KB
testcase_24 AC 97 ms
6,676 KB
testcase_25 AC 65 ms
6,676 KB
testcase_26 AC 84 ms
6,676 KB
testcase_27 AC 65 ms
6,676 KB
testcase_28 AC 80 ms
6,676 KB
testcase_29 AC 95 ms
6,676 KB
testcase_30 AC 71 ms
6,676 KB
testcase_31 AC 86 ms
6,676 KB
testcase_32 AC 51 ms
6,676 KB
testcase_33 AC 152 ms
6,676 KB
testcase_34 AC 25 ms
6,676 KB
testcase_35 AC 84 ms
6,676 KB
testcase_36 AC 78 ms
6,676 KB
testcase_37 AC 20 ms
6,676 KB
testcase_38 AC 2 ms
6,676 KB
testcase_39 AC 2 ms
6,676 KB
testcase_40 AC 127 ms
6,676 KB
testcase_41 AC 128 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// Problem: No.2604 Initial Motion
// Contest: yukicoder
// URL: https://yukicoder.me/problems/no/2604
// Memory Limit: 512 MB
// Time Limit: 3000 ms

#include<bits/stdc++.h>
#include <atcoder/mincostflow>
#define debug(x) cerr<<(#x)<<" "<<(x)<<endl
using namespace atcoder;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<ll,ll>
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define per(i,a,b) for(ll i=(a);i>=(b);--i)
using namespace std;
ll read(){
	ll x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);
	putchar(x%10+'0');
}
const ll N=2e3+5,INF=1e18;
ll n,m;
ll a[N],b[N],k;
vector<pii>to[N];
int main(){
	k=read(),n=read(),m=read();
	rep(i,1,k)a[i]=read();
	rep(i,1,n)b[i]=read();
    mcf_graph<ll, ll> g(n+2);
    ll s = 0, t = n+1;
    rep(i,1,k)g.add_edge(s,a[i],1,0);
    rep(i,1,n){
    	if(b[i])g.add_edge(i,t,b[i],0);
    }
	rep(i,1,m){
		ll x=read(),y=read(),z=read();
		g.add_edge(x,y,INF,z);
		g.add_edge(y,x,INF,z);
	}
    pii result = g.flow(s, t, INF);
	write(result.second);
	return 0;
}

0