結果

問題 No.909 たぴの配置
コンテスト
ユーザー nebukuro09
提出日時 2019-10-18 21:30:07
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
AC  
実行時間 232 ms / 3,000 ms
コード長 696 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 648 ms
コンパイル使用メモリ 100,152 KB
実行使用メモリ 21,480 KB
最終ジャッジ日時 2026-03-06 08:05:47
合計ジャッジ時間 4,512 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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