結果

問題 No.198 キャンディー・ボックス2
ユーザー te-shte-sh
提出日時 2016-09-15 14:23:16
言語 D
(dmd 2.107.1)
結果
WA  
実行時間 -
コード長 589 bytes
コンパイル時間 829 ms
コンパイル使用メモリ 110,964 KB
実行使用メモリ 4,496 KB
最終ジャッジ日時 2023-09-02 22:10:18
合計ジャッジ時間 3,436 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
4,368 KB
testcase_03 AC 1 ms
4,368 KB
testcase_04 RE -
testcase_05 RE -
testcase_06 WA -
testcase_07 RE -
testcase_08 WA -
testcase_09 AC 1 ms
4,368 KB
testcase_10 AC 2 ms
4,368 KB
testcase_11 AC 1 ms
4,372 KB
testcase_12 AC 2 ms
4,368 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,368 KB
testcase_15 AC 1 ms
4,372 KB
testcase_16 AC 1 ms
4,372 KB
testcase_17 AC 1 ms
4,372 KB
testcase_18 AC 2 ms
4,368 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 RE -
testcase_22 RE -
testcase_23 WA -
testcase_24 AC 1 ms
4,372 KB
testcase_25 WA -
testcase_26 AC 2 ms
4,372 KB
testcase_27 AC 1 ms
4,368 KB
testcase_28 RE -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.array, std.container, std.range, std.bitmanip;
import std.numeric, std.math, std.bigint, std.random, core.bitop;
import std.string, std.regex, std.conv, std.stdio, std.typecons;

void main()
{
  auto b = readln.chomp.to!int;
  auto n = readln.chomp.to!size_t;
  auto ci = iota(n).map!(_ => readln.chomp.to!int).array;

  auto maxR = (ci.sum + b) / n;

  int calc(int r) { return ci.map!(c => (c - r).abs).sum; }

  auto s = iota(maxR + 1)
    .map!(r => calc((r + 1).to!int) - calc(r.to!int))
    .assumeSorted.lowerBound(0);

  writeln(calc(s.length.to!int));
}
0