結果

問題 No.625 ソンタクロース
ユーザー te-shte-sh
提出日時 2018-08-24 17:47:01
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 63 ms / 4,000 ms
コード長 822 bytes
コンパイル時間 1,176 ms
コンパイル使用メモリ 111,440 KB
実行使用メモリ 7,300 KB
最終ジャッジ日時 2023-09-03 20:53:34
合計ジャッジ時間 2,333 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 7 ms
4,380 KB
testcase_16 AC 4 ms
4,380 KB
testcase_17 AC 29 ms
7,264 KB
testcase_18 AC 63 ms
7,300 KB
testcase_19 AC 11 ms
4,488 KB
testcase_20 AC 11 ms
5,124 KB
testcase_21 AC 7 ms
4,376 KB
testcase_22 AC 52 ms
7,220 KB
testcase_23 AC 6 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void writeA(T)(size_t n,T t){foreach(i,v;t.enumerate){write(v);if(i<n-1)write(" ");}writeln;}

void main()
{
  int n, m; readV(n, m);

  auto p = [m];
  foreach (i; 2..n+1) {
    auto s = p.enumerate.array;
    s.sort!"a[1] == b[1] ? a[0]<b[0] : a[1]<b[1]";
    s = s[0..i/2];
    if (s.map!"a[1]".sum + i/2 > m) {
      p ~= -1;
      continue;
    }

    auto v = new bool[](i-1);
    foreach (si; s) {
      ++p[si[0]];
      v[si[0]] = true;
    }
    foreach (j; 0..i-1)
      if (!v[j]) p[j] = 0;

    p ~= m - p.sum;
  }

  writeA(n, p.retro);
}
0