結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー kaiyori_labkaiyori_lab
提出日時 2015-01-09 03:09:33
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 66 ms / 5,000 ms
コード長 595 bytes
コンパイル時間 1,129 ms
コンパイル使用メモリ 114,584 KB
実行使用メモリ 4,496 KB
最終ジャッジ日時 2023-09-02 19:36:18
合計ジャッジ時間 1,530 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
4,368 KB
testcase_01 AC 63 ms
4,496 KB
testcase_02 AC 22 ms
4,368 KB
testcase_03 AC 66 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[2] == 0 ){ return acc; } else { --xs[0..3]; }
  return solve(xs, ++acc);
}

// 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