結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー kaiyori_labkaiyori_lab
提出日時 2015-01-09 02:26:31
言語 D
(dmd 2.105.2)
結果
AC  
実行時間 80 ms / 5,000 ms
コード長 600 bytes
コンパイル時間 1,007 ms
コンパイル使用メモリ 115,036 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-09-02 19:35:53
合計ジャッジ時間 1,580 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
4,372 KB
testcase_01 AC 77 ms
4,372 KB
testcase_02 AC 25 ms
4,372 KB
testcase_03 AC 80 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

// solve =============
T solve(T)(T[] xs, T acc = 0){
  xs.sort.reverse;
  if( xs[0..3].any!("a==0") ) return acc; else --xs[0..3];
  return solve(xs, acc + 1);
}

// main ===============
void main(){
  readln;
  foreach(line; stdin.byLine){
    if(line.empty) break;
    auto ls = readln.chomp.split(" ").map!(to!int).array.sort;
    auto groupLs = ls.group.map!("a[1]").array;  //uint
    writeln( groupLs.length >= 3 ? solve(groupLs) : 0 );
  }
}
0