結果

問題 No.909 たぴの配置
ユーザー nebukuro09
提出日時 2019-10-18 21:30:07
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 123 ms / 3,000 ms
コード長 696 bytes
コンパイル時間 784 ms
コンパイル使用メモリ 119,776 KB
実行使用メモリ 22,064 KB
最終ジャッジ日時 2024-06-22 02:47:16
合計ジャッジ時間 4,582 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

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.string;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.split.map!(to!int).array;
    auto B = readln.split.map!(to!int).array;

    int ans = N.iota.map!(i => A[i] + B[i]).reduce!min;
    ans.writeln;

    auto anss = new int[](N + 2);

    foreach (i; 0..N) {
        if (A[i] <= B[i]) {
            anss[i + 1] = A[i];
        } else {
            anss[i + 1] = ans - B[i];
        }
    }

    anss.back = ans;

    auto m = anss.reduce!min;

    anss.each!(a => writeln(a - m));
}
0