結果

問題 No.250 atetubouのzetubou
ユーザー te-shte-sh
提出日時 2017-05-25 17:30:11
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 51 ms / 5,000 ms
コード長 872 bytes
コンパイル時間 1,405 ms
コンパイル使用メモリ 158,336 KB
実行使用メモリ 45,484 KB
最終ジャッジ日時 2023-09-03 13:36:34
合計ジャッジ時間 3,308 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
44,256 KB
testcase_01 AC 40 ms
42,864 KB
testcase_02 AC 51 ms
45,484 KB
testcase_03 AC 51 ms
45,452 KB
testcase_04 AC 49 ms
44,932 KB
testcase_05 AC 49 ms
44,024 KB
testcase_06 AC 48 ms
45,204 KB
testcase_07 AC 43 ms
43,480 KB
testcase_08 AC 49 ms
44,516 KB
testcase_09 AC 47 ms
45,180 KB
testcase_10 AC 49 ms
43,988 KB
testcase_11 AC 46 ms
43,948 KB
testcase_12 AC 49 ms
44,236 KB
testcase_13 AC 44 ms
44,224 KB
testcase_14 AC 39 ms
43,724 KB
testcase_15 AC 23 ms
14,852 KB
testcase_16 AC 22 ms
14,872 KB
testcase_17 AC 23 ms
14,868 KB
testcase_18 AC 22 ms
14,824 KB
testcase_19 AC 23 ms
14,892 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 8 ms
8,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.bigint;    // BigInt

const inf = 10L ^^ 15 + 1;

void main()
{
  auto q = readln.chomp.to!size_t;
  auto di = new int[](q), xi = new int[](q), ti = new long[](q);
  foreach (i; 0..q) {
    auto rd = readln.split;
    di[i] = rd[0].to!int; xi[i] = rd[1].to!int; ti[i] = rd[2].to!long;
  }

  auto maxXD = zip(di, xi).map!"a[0] + a[1]".maxElement - 1;
  auto pt = pascalTriangle!long(maxXD);

  foreach (d, x, t; lockstep(di, xi, ti)) {
    auto c = pt[x+d-1][d-1];
    writeln(c <= t ? "AC" : "ZETUBOU");
  }
}

pure T[][] pascalTriangle(T)(size_t n)
{
  auto t = new T[][](n + 1);
  t[0] = new T[](1);
  t[0][0] = 1;
  foreach (i; 1..n+1) {
    t[i] = new T[](i + 1);
    t[i][0] = t[i][$-1] = 1;
    foreach (j; 1..i)
      t[i][j] = min(inf, t[i - 1][j - 1] + t[i - 1][j]);
  }
  return t;
}
0