結果

問題 No.2321 Continuous Flip
ユーザー 👑 hitonanodehitonanode
提出日時 2023-05-26 23:32:33
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 349 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 1,646 ms
コンパイル使用メモリ 127,532 KB
実行使用メモリ 119,964 KB
最終ジャッジ日時 2023-08-26 13:56:12
合計ジャッジ時間 12,792 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 317 ms
119,964 KB
testcase_05 AC 279 ms
118,976 KB
testcase_06 AC 333 ms
118,776 KB
testcase_07 AC 283 ms
119,344 KB
testcase_08 AC 337 ms
119,148 KB
testcase_09 AC 335 ms
119,368 KB
testcase_10 AC 319 ms
118,860 KB
testcase_11 AC 339 ms
117,764 KB
testcase_12 AC 312 ms
118,484 KB
testcase_13 AC 347 ms
118,088 KB
testcase_14 AC 338 ms
118,564 KB
testcase_15 AC 302 ms
117,824 KB
testcase_16 AC 344 ms
118,484 KB
testcase_17 AC 335 ms
118,564 KB
testcase_18 AC 308 ms
119,128 KB
testcase_19 AC 348 ms
118,128 KB
testcase_20 AC 349 ms
118,608 KB
testcase_21 AC 334 ms
118,124 KB
testcase_22 AC 314 ms
118,408 KB
testcase_23 AC 280 ms
119,012 KB
testcase_24 AC 273 ms
118,700 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 240 ms
118,216 KB
testcase_27 AC 259 ms
118,312 KB
testcase_28 AC 304 ms
118,448 KB
testcase_29 AC 304 ms
118,080 KB
testcase_30 AC 287 ms
119,340 KB
testcase_31 AC 303 ms
118,084 KB
testcase_32 AC 304 ms
118,292 KB
testcase_33 AC 289 ms
118,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <atcoder/mincostflow>
using namespace std;

int main() {
    long long N, M, C, a, l, r, ret = 0;
    cin >> N >> M >> C;
    atcoder::mcf_graph<int, long long> mcf(N + 1);
    for (int i = 0; i < N; ++i) cin >> a, mcf.add_edge(i, i + 1, 1, a), mcf.add_edge(i + 1, i, 1, a), ret += a;
    while (M--) cin >> l >> r, --l, mcf.add_edge(l, r, 1, C), mcf.add_edge(r, l, 1, C);
    cout << ret - mcf.flow(0, N, 1).second << endl;
}
0