結果

問題 No.2321 Continuous Flip
ユーザー 沙耶花沙耶花
提出日時 2023-05-26 22:28:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 408 ms / 2,000 ms
コード長 633 bytes
コンパイル時間 4,625 ms
コンパイル使用メモリ 274,996 KB
実行使用メモリ 125,872 KB
最終ジャッジ日時 2023-08-26 12:32:22
合計ジャッジ時間 17,290 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 353 ms
125,872 KB
testcase_05 AC 306 ms
125,756 KB
testcase_06 AC 379 ms
124,916 KB
testcase_07 AC 311 ms
124,992 KB
testcase_08 AC 392 ms
125,164 KB
testcase_09 AC 385 ms
124,940 KB
testcase_10 AC 362 ms
124,708 KB
testcase_11 AC 389 ms
124,780 KB
testcase_12 AC 360 ms
125,316 KB
testcase_13 AC 399 ms
125,392 KB
testcase_14 AC 384 ms
124,652 KB
testcase_15 AC 332 ms
125,160 KB
testcase_16 AC 390 ms
124,792 KB
testcase_17 AC 387 ms
124,464 KB
testcase_18 AC 353 ms
125,456 KB
testcase_19 AC 408 ms
125,084 KB
testcase_20 AC 407 ms
124,992 KB
testcase_21 AC 385 ms
124,588 KB
testcase_22 AC 363 ms
125,500 KB
testcase_23 AC 305 ms
125,076 KB
testcase_24 AC 295 ms
124,548 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 252 ms
125,100 KB
testcase_27 AC 277 ms
124,524 KB
testcase_28 AC 350 ms
125,016 KB
testcase_29 AC 349 ms
125,004 KB
testcase_30 AC 327 ms
124,976 KB
testcase_31 AC 350 ms
125,292 KB
testcase_32 AC 346 ms
124,824 KB
testcase_33 AC 326 ms
125,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001
#define sq 1300


int main(){
	
	int n,m,c;
	cin>>n>>m>>c;
	mcf_graph<long long,long long> G(n+1);
	long long ans = 0;
	rep(i,n){
		int a;
		cin>>a;
		ans += a;
		G.add_edge(i,i+1,1,a);
		G.add_edge(i+1,i,1,a);
	}
	
	rep(i,m){
		int l,r;
		cin>>l>>r;
		l--;
		G.add_edge(l,r,1,c);
		G.add_edge(r,l,1,c);
	}
	ans -= G.flow(0,n,1).second;
	//ans *= -1;
	
	cout<<ans<<endl;
	return 0;
}
0