結果
問題 | No.957 植林 |
ユーザー |
|
提出日時 | 2019-12-19 23:14:55 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 931 bytes |
コンパイル時間 | 899 ms |
コンパイル使用メモリ | 126,836 KB |
実行使用メモリ | 7,204 KB |
最終ジャッジ日時 | 2024-06-22 03:54:41 |
合計ジャッジ時間 | 2,920 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 WA * 27 |
ソースコード
import std.stdio, std.array, std.string, std.conv, std.algorithm;import std.typecons, std.range, std.random, std.math, std.container;import std.numeric, std.bigint, core.bitop, core.stdc.stdio;void main() {auto s = readln.split.map!(to!int);auto H = s[0];auto W = s[1];auto A = iota(H).map!(_ => readln.split.map!(to!long).array).array;auto R = readln.split.map!(to!long).array;auto C = readln.split.map!(to!long).array;foreach (i; 0..H) A[i] ~= R[i] - A[i].sum;A.sort!"a.back > b.back";long csum = 0;foreach (j; 0..W) foreach (i; 0..H) C[j] -= A[i][j];foreach (j; 0..W) csum += max(0L, C[j]);auto ans = csum;auto tmp = csum;foreach (i; 0..H) {tmp += A[i].back;foreach (j; 0..W) {C[j] += A[i][j];tmp += max(0L, C[j] - max(C[j] - A[i][j], 0L));}ans = max(ans, tmp);}ans.writeln;}