結果

問題 No.91 赤、緑、青の石
ユーザー kaiyori_labkaiyori_lab
提出日時 2014-12-07 21:24:10
言語 D
(dmd 2.105.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 690 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 94,472 KB
最終ジャッジ日時 2023-09-02 19:20:53
合計ジャッジ時間 1,216 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
Main.d(14): Error: cannot implicitly convert expression `sort(array(map(stones)))` of type `SortedRange!(int[], "a < b", SortedRangeOptions.assumeSorted)` to `int[]`
Main.d(22): Error: function `Main.main.canMake(int[] s, int acc)` is not callable using argument types `(SortedRange!(int[], "a < b", SortedRangeOptions.assumeSorted), int)`
Main.d(22):        cannot pass argument `sort(s)` of type `SortedRange!(int[], "a < b", SortedRangeOptions.assumeSorted)` to parameter `int[] s`
Main.d(26): Error: function `Main.main.canMake(int[] s, int acc)` is not callable using argument types `(SortedRange!(int[], "a < b", SortedRangeOptions.assumeSorted), int)`
Main.d(26):        cannot pass argument `sort(s)` of type `SortedRange!(int[], "a < b", SortedRangeOptions.assumeSorted)` to parameter `int[] s`

ソースコード

diff #

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

void main(){
  auto stones = readln.chomp.split(" ").map!(to!int).array;
  int res;

  int tempMin = stones.reduce!min;
  res += tempMin;
  stones = stones.map!((e) => e - tempMin).array.sort;

  int canMake(int[] s, int acc){
    bool cond1 = s[2]>2 && s[1]>=1;
    bool cond2 = s[2]>4 && s[1]<1;
    if(cond1){
      s[2] -= 3;
      s[1] -= 1;
      return canMake(s.sort, acc + 1);
    }
    else if(cond2){
     s[2] -= 5;
     return canMake(s.sort, acc+1);
    }
    else{ return acc; }
  }
  res += canMake(stones, 0);
  res.writeln;
}

0