結果

問題 No.250 atetubouのzetubou
ユーザー te-sh
提出日時 2017-05-25 17:30:11
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 62 ms / 5,000 ms
コード長 872 bytes
コンパイル時間 1,494 ms
コンパイル使用メモリ 148,456 KB
実行使用メモリ 43,560 KB
最終ジャッジ日時 2024-06-12 19:26:25
合計ジャッジ時間 2,790 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

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