結果
| 問題 | No.957 植林 |
| コンテスト | |
| ユーザー |
bal4u
|
| 提出日時 | 2019-12-21 16:06:42 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,113 bytes |
| 記録 | |
| コンパイル時間 | 361 ms |
| コンパイル使用メモリ | 31,088 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-19 15:45:27 |
| 合計ジャッジ時間 | 2,715 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 WA * 40 |
ソースコード
// 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;
}
bal4u