結果

問題 No.2604 Initial Motion
ユーザー FplusFplusF
提出日時 2024-01-13 03:09:21
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 139 ms / 3,000 ms
コード長 938 bytes
コンパイル時間 3,684 ms
コンパイル使用メモリ 270,576 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-28 01:10:01
合計ジャッジ時間 6,252 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 39
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/mincostflow>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
template<class T> void chmin(T &a,T b){
    if(a>b){
        a=b;
    }
}
template<class T> void chmax(T &a,T b){
    if(a<b){
        a=b;
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll k,n,m;
    cin >> k >> n >> m;
    atcoder::mcf_graph<ll,ll> g(n+2);
    while(k--){
        ll a;
        cin >> a;
        a--;
        g.add_edge(n,a,1,0);
    }
    rep(i,n){
        ll b;
        cin >> b;
        g.add_edge(i,n+1,b,0);
    }
    while(m--){
        ll u,v,d;
        cin >> u >> v >> d;
        u--;
        v--;
        g.add_edge(u,v,INF,d);
        g.add_edge(v,u,INF,d);
    }
    cout << g.flow(n,n+1).second << '\n';
}
0