結果

問題 No.957 植林
ユーザー 沙耶花沙耶花
提出日時 2023-06-03 14:53:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 425 ms / 2,000 ms
コード長 921 bytes
コンパイル時間 4,600 ms
コンパイル使用メモリ 269,264 KB
実行使用メモリ 9,888 KB
最終ジャッジ日時 2023-08-28 07:54:57
合計ジャッジ時間 16,257 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 37 ms
8,784 KB
testcase_04 AC 35 ms
8,600 KB
testcase_05 AC 37 ms
8,780 KB
testcase_06 AC 40 ms
9,192 KB
testcase_07 AC 36 ms
8,508 KB
testcase_08 AC 31 ms
8,736 KB
testcase_09 AC 32 ms
8,688 KB
testcase_10 AC 34 ms
9,372 KB
testcase_11 AC 33 ms
8,664 KB
testcase_12 AC 32 ms
8,660 KB
testcase_13 AC 28 ms
7,452 KB
testcase_14 AC 34 ms
9,468 KB
testcase_15 AC 31 ms
9,064 KB
testcase_16 AC 28 ms
7,860 KB
testcase_17 AC 30 ms
8,436 KB
testcase_18 AC 262 ms
8,768 KB
testcase_19 AC 271 ms
9,028 KB
testcase_20 AC 281 ms
8,980 KB
testcase_21 AC 293 ms
8,984 KB
testcase_22 AC 317 ms
9,256 KB
testcase_23 AC 322 ms
9,296 KB
testcase_24 AC 335 ms
9,420 KB
testcase_25 AC 352 ms
9,560 KB
testcase_26 AC 349 ms
9,692 KB
testcase_27 AC 345 ms
9,744 KB
testcase_28 AC 346 ms
9,744 KB
testcase_29 AC 347 ms
9,684 KB
testcase_30 AC 350 ms
9,888 KB
testcase_31 AC 347 ms
8,752 KB
testcase_32 AC 364 ms
9,140 KB
testcase_33 AC 374 ms
8,972 KB
testcase_34 AC 391 ms
9,168 KB
testcase_35 AC 415 ms
9,608 KB
testcase_36 AC 425 ms
9,448 KB
testcase_37 AC 339 ms
9,284 KB
testcase_38 AC 352 ms
9,788 KB
testcase_39 AC 352 ms
9,668 KB
testcase_40 AC 350 ms
9,884 KB
testcase_41 AC 22 ms
9,536 KB
testcase_42 AC 22 ms
9,556 KB
testcase_43 AC 46 ms
9,560 KB
testcase_44 AC 47 ms
9,748 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 1 ms
4,376 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 Inf48 5000000000000

int main(){
	
	int h,w;
	cin>>h>>w;
	vector g(h,vector<long long>(w));
	long long ans = 0;
	rep(i,h){
		rep(j,w){
			cin>>g[i][j];
			ans += g[i][j];
		}
	}
	
	vector<long long> rc0(h+w,Inf48);
	auto rc1 = rc0;
	rep(i,h+w){
		long long t;
		cin>>t;
		rc1[i] -= t;
	}
	
	rep(i,h){
		rep(j,w){
			rc0[i] -= g[i][j];
		}
	}
	
	mf_graph<long long> G(h+w + 2);
	int s = (h+w);
	int t = s+1;
	rep(i,h+w){
		G.add_edge(s,i,rc0[i]);
		G.add_edge(i,t,rc1[i]);
	}
	rep(i,h){
		rep(j,w){
			G.add_edge(h+j,i,g[i][j]);
		}
	}
	//cout<<ans<<endl;
	ans += G.flow(s,t);
	//cout<<ans<<endl;
	ans -= Inf48 * (h+w);
	ans *= -1;
	cout<<ans<<endl;
	
	return 0;
}
0