結果

問題 No.110 しましまピラミッド
ユーザー te-sh
提出日時 2016-08-30 17:00:00
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 762 bytes
コンパイル時間 1,052 ms
コンパイル使用メモリ 122,944 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-12 03:52:18
合計ジャッジ時間 2,141 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

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

void main()
{
  auto nw = readln.chomp.to!int;
  auto wi = readln.split.map!(to!int).array;
  auto nb = readln.chomp.to!int;
  auto bi = readln.split.map!(to!int).array;

  wi.sort!("a > b");
  bi.sort!("a > b");

  writeln(max(calc(wi, bi, 0, 0), calc(bi, wi, 0, 0)));
}

int calc(int[] ai, int[] bi, int prev, int acc)
{
  if (ai.empty) {
    return acc;
  } else if (prev == 0) {
    return calc(bi, ai[1..$], ai.front, acc + 1);
  } else {
    auto ci = ai.find!(x => x < prev);
    if (ci.empty)
      return acc;
    else
      return calc(bi, ci[1..$], ci.front, acc + 1);
  }
}
0