結果

問題 No.2321 Continuous Flip
ユーザー t98slidert98slider
提出日時 2023-05-27 06:58:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 245 ms / 2,000 ms
コード長 571 bytes
コンパイル時間 3,776 ms
コンパイル使用メモリ 244,996 KB
実行使用メモリ 119,760 KB
最終ジャッジ日時 2023-08-26 17:24:06
合計ジャッジ時間 12,324 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 224 ms
118,404 KB
testcase_05 AC 198 ms
118,204 KB
testcase_06 AC 235 ms
118,328 KB
testcase_07 AC 180 ms
118,656 KB
testcase_08 AC 240 ms
119,352 KB
testcase_09 AC 230 ms
118,796 KB
testcase_10 AC 215 ms
118,196 KB
testcase_11 AC 240 ms
119,396 KB
testcase_12 AC 205 ms
118,228 KB
testcase_13 AC 244 ms
118,552 KB
testcase_14 AC 234 ms
119,760 KB
testcase_15 AC 188 ms
118,608 KB
testcase_16 AC 234 ms
118,624 KB
testcase_17 AC 240 ms
119,000 KB
testcase_18 AC 202 ms
117,968 KB
testcase_19 AC 245 ms
119,504 KB
testcase_20 AC 245 ms
118,196 KB
testcase_21 AC 228 ms
118,528 KB
testcase_22 AC 205 ms
118,300 KB
testcase_23 AC 173 ms
118,276 KB
testcase_24 AC 152 ms
118,268 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 129 ms
118,484 KB
testcase_27 AC 145 ms
119,544 KB
testcase_28 AC 211 ms
118,332 KB
testcase_29 AC 199 ms
118,796 KB
testcase_30 AC 182 ms
118,548 KB
testcase_31 AC 197 ms
118,456 KB
testcase_32 AC 202 ms
118,128 KB
testcase_33 AC 181 ms
118,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, c, v, u;
    ll s = 0;
    cin >> n >> m >> c;
    atcoder::mcf_graph<int, ll> g(n + 1);
    for(int i = 0; i < n; i++){
        cin >> v;
        s += v;
        g.add_edge(i, i + 1, 1, v);
        g.add_edge(i + 1, i, 1, v);
    }
    while(m--){
        cin >> u >> v;
        u--;
        g.add_edge(u, v, 1, c);
        g.add_edge(v, u, 1, c);
    }
    cout << s - g.flow(0, n, 1).second << '\n';
}
0