結果

問題 No.957 植林
ユーザー bal4ubal4u
提出日時 2019-12-21 16:06:42
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,113 bytes
コンパイル時間 646 ms
コンパイル使用メモリ 30,264 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-09-26 21:57:43
合計ジャッジ時間 4,727 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 2 ms
4,376 KB
testcase_42 WA -
testcase_43 AC 4 ms
4,380 KB
testcase_44 AC 4 ms
4,376 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 0 ms
4,376 KB
testcase_47 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

// yuki 957 植林
// 2019.12.21 bal4u

#include <stdio.h>
#include <ctype.h>
#include <string.h>

typedef long long ll;

int getchar_unlocked(void);
#define gc() getchar_unlocked()
//#define gc() getchar()

int in() {  // 整数の入力
	int n = 0; int c;
	do c = gc(); while (isspace(c));
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

int g[305][305];
ll sr[305], sc[305];
int R[305], C[305];

int main()
{
	int r, c, H, W;
	ll ans, s, t;
	
	H = in(), W = in();
	for (r = 0; r < H; ++r) for (c = 0; c < W; ++c) {
		g[r][c] = in(), sr[r] += g[r][c];
	}
	for (c = 0; c < W; ++c) for (r = 0; r < H; ++r) {
		sc[c] += g[r][c];
	}
	
	for (r = 0; r < H; ++r) R[r] = in();
	for (c = 0; c < W; ++c) C[c] = in();
	
	ans = 0;
	for (r = 0; r < H; ++r) {
		if ((t = R[r] - sr[r]) > 0) ans += t;
	}
	
	s = 0;
	for (c = 0; c < W; ++c) {
		if ((t = C[c] - sc[c]) > 0) s += t;
	}
	if (s > ans) ans = t;
	
	s = 0;
	for (r = 0; r < H; ++r) for (c = 0; c < W; ++c) {
		t = (ll)R[r] + C[c] + (ll)g[r][c] - (sr[r] + sc[c]);
		if (t > 0) s += t;
	}
	if (s > ans) ans = s;
	
	printf("%lld\n", ans);
	return 0;
}
0