結果

問題 No.110 しましまピラミッド
ユーザー kaiyori_labkaiyori_lab
提出日時 2014-12-24 14:52:01
言語 D
(dmd 2.105.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 670 bytes
コンパイル時間 400 ms
コンパイル使用メモリ 87,068 KB
最終ジャッジ日時 2023-09-02 19:25:40
合計ジャッジ時間 1,804 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
Main.d(24): Error: function `Main.loop(int[] xs, int[] ys, int before = 2147483647, int acc = 0)` is not callable using argument types `(SortedRange!(int[], "a < b", SortedRangeOptions.assumeSorted), SortedRange!(int[], "a < b", SortedRangeOptions.assumeSorted))`
Main.d(24):        cannot pass argument `ws` of type `SortedRange!(int[], "a < b", SortedRangeOptions.assumeSorted)` to parameter `int[] xs`
Main.d(24): Error: function `Main.loop(int[] xs, int[] ys, int before = 2147483647, int acc = 0)` is not callable using argument types `(SortedRange!(int[], "a < b", SortedRangeOptions.assumeSorted), SortedRange!(int[], "a < b", SortedRangeOptions.assumeSorted))`
Main.d(24):        cannot pass argument `bs` of type `SortedRange!(int[], "a < b", SortedRangeOptions.assumeSorted)` to parameter `int[] xs`

ソースコード

diff #

import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.array;

// つながりの長さを求める(xsから始める) --------------------
int loop(int[] xs, int[]  ys, int before=int.max, int acc=0){
  if(!xs.length) return acc;
  if(xs[$-1] < before) return loop(ys, xs[0..$-1], xs[$-1], acc+1);
  return xs.length >= 1 ? loop(xs[0..$-1], ys, before, acc): acc;
}

// main----------------
void main(){
  //input
  readln;
  auto ws = readln.chomp.split(" ").map!(to!int).array.sort;
  readln;
  auto bs = readln.chomp.split(" ").map!(to!int).array.sort;

  //solve
  writeln( max(loop(ws, bs), loop(bs, ws)) );
}
0