結果

問題 No.957 植林
ユーザー nebukuro09nebukuro09
提出日時 2019-12-19 23:14:55
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 931 bytes
コンパイル時間 1,002 ms
コンパイル使用メモリ 113,596 KB
実行使用メモリ 7,764 KB
最終ジャッジ日時 2023-09-04 04:22:13
合計ジャッジ時間 3,091 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 16 ms
7,520 KB
testcase_06 AC 15 ms
7,240 KB
testcase_07 WA -
testcase_08 AC 15 ms
7,272 KB
testcase_09 AC 14 ms
6,448 KB
testcase_10 AC 14 ms
6,200 KB
testcase_11 AC 13 ms
5,928 KB
testcase_12 WA -
testcase_13 AC 13 ms
4,676 KB
testcase_14 AC 15 ms
6,204 KB
testcase_15 AC 14 ms
6,652 KB
testcase_16 AC 13 ms
6,456 KB
testcase_17 AC 13 ms
6,204 KB
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 10 ms
6,200 KB
testcase_42 AC 10 ms
6,200 KB
testcase_43 AC 23 ms
7,764 KB
testcase_44 AC 23 ms
7,712 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 1 ms
4,380 KB
testcase_47 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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;
}
0