結果

問題 No.120 傾向と対策:門松列(その1)
ユーザー 6soukiti296soukiti29
提出日時 2017-09-02 13:48:17
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 617 bytes
コンパイル時間 3,121 ms
コンパイル使用メモリ 68,896 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-12 15:03:56
合計ジャッジ時間 3,857 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sequtils,strutils,algorithm
var
    T = stdin.readline.parseInt
for t in 1..T:
    var
        N = stdin.readline.parseInt
        L = stdin.readline.split.map(parseInt)
        A : array[2, int]
        cnt : int
        a,b : int
    L.sort(system.cmp)
    for l in L:
        if A[0] == 0 or l == a:
            A[0] += 1
            a = l
        elif A[1] == 0 or l == b:
            A[1] += 1
            b = l
        else:
            A[0] -= 1
            A[1] -= 1
            cnt += 1
            if A[0] == 0:
                A[0] = A[1]
                a = b
                A[1] = 0

    echo cnt
0