結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー diginatudiginatu
提出日時 2015-01-09 01:06:40
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 42 ms / 5,000 ms
コード長 574 bytes
コンパイル時間 1,728 ms
コンパイル使用メモリ 164,184 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-09-02 19:35:51
合計ジャッジ時間 2,404 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

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

void main(){
  auto T = readln().strip().to!int();

  foreach(immutable i; 0 .. T) {
    auto N = readln().strip().to!int();
    auto L = readln().strip().split().map!(to!int)().array;

    L.sort();
    auto tps = L.group().map!"a[1]"().array();
    if(tps.length < 3) {
      writeln(0);
      continue;
    }

    int ans;

    for(;;) {
      tps.topN!"a > b"(3);
      if(tps[0 .. 3].any!"a == 0"()) break;
      -- tps[0 .. 3];
      ++ ans;
    }

    writeln(ans);
  }
}
0