結果

問題 No.957 植林
ユーザー yuruhiyayuruhiya
提出日時 2021-03-22 13:19:42
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 351 ms / 2,000 ms
コード長 645 bytes
コンパイル時間 2,617 ms
コンパイル使用メモリ 148,424 KB
実行使用メモリ 9,844 KB
最終ジャッジ日時 2023-08-15 15:53:37
合計ジャッジ時間 11,360 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 32 ms
8,920 KB
testcase_04 AC 29 ms
8,532 KB
testcase_05 AC 32 ms
8,852 KB
testcase_06 AC 35 ms
9,180 KB
testcase_07 AC 31 ms
8,612 KB
testcase_08 AC 27 ms
8,944 KB
testcase_09 AC 27 ms
9,060 KB
testcase_10 AC 29 ms
9,264 KB
testcase_11 AC 27 ms
8,712 KB
testcase_12 AC 26 ms
8,668 KB
testcase_13 AC 23 ms
7,484 KB
testcase_14 AC 29 ms
9,012 KB
testcase_15 AC 26 ms
9,100 KB
testcase_16 AC 23 ms
7,808 KB
testcase_17 AC 25 ms
8,488 KB
testcase_18 AC 216 ms
8,752 KB
testcase_19 AC 227 ms
9,020 KB
testcase_20 AC 246 ms
9,168 KB
testcase_21 AC 242 ms
9,228 KB
testcase_22 AC 258 ms
9,380 KB
testcase_23 AC 276 ms
9,372 KB
testcase_24 AC 286 ms
9,256 KB
testcase_25 AC 301 ms
9,580 KB
testcase_26 AC 301 ms
9,844 KB
testcase_27 AC 300 ms
9,568 KB
testcase_28 AC 298 ms
9,744 KB
testcase_29 AC 351 ms
9,564 KB
testcase_30 AC 300 ms
9,628 KB
testcase_31 AC 217 ms
8,908 KB
testcase_32 AC 225 ms
9,020 KB
testcase_33 AC 244 ms
9,076 KB
testcase_34 AC 241 ms
9,184 KB
testcase_35 AC 263 ms
9,264 KB
testcase_36 AC 280 ms
9,268 KB
testcase_37 AC 285 ms
9,272 KB
testcase_38 AC 299 ms
9,516 KB
testcase_39 AC 301 ms
9,636 KB
testcase_40 AC 301 ms
9,588 KB
testcase_41 AC 19 ms
9,636 KB
testcase_42 AC 18 ms
9,508 KB
testcase_43 AC 40 ms
9,724 KB
testcase_44 AC 45 ms
9,628 KB
testcase_45 AC 1 ms
4,380 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; ++i)

int main() {
	int h, w;
	cin >> h >> w;
	ll a[301][301], b[301], c[301];
	rep(i, h) rep(j, w) cin >> a[i][j];
	rep(i, h) cin >> b[i];
	rep(i, w) cin >> c[i];

	int size = h + w + 2, S = size - 2, T = size - 1;
	atcoder::mf_graph<ll> g(size);

	ll sum = 0;
	rep(i, h) {
		ll s = 0;
		rep(j, w) s += a[i][j];
		g.add_edge(S, i, s);
		g.add_edge(i, T, b[i]);
		sum += b[i];
	}
	rep(j, w) {
		g.add_edge(h + j, T, c[j]);
		sum += c[j];
	}
	rep(i, h) rep(j, w) {
		g.add_edge(i, h + j, a[i][j]);
	}
	cout << sum - g.flow(S, T) << '\n';
}
0