結果

問題 No.133 カードゲーム
ユーザー toshiro_yanagitoshiro_yanagi
提出日時 2019-01-27 17:06:13
言語 Nim
(2.0.2)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 841 bytes
コンパイル時間 894 ms
コンパイル使用メモリ 65,800 KB
最終ジャッジ日時 2024-04-27 02:47:06
合計ジャッジ時間 1,361 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 8) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated]
/home/judge/data/code/Main.nim(20, 12) Error: undeclared identifier: 'lc'

ソースコード

diff #

import future, strutils, algorithm


proc nextString: string =
    result = ""
    while not endOfFile stdin:
        let c = readChar stdin
        if c == ' ' or c == "\n"[0]: break
        elif c != '\r': add result, c


proc nextInt: int =
    parseInt nextString()


let
    n = nextInt()

var
    A, B = lc[nextInt() | (i <- 0 ..< n), int].sorted(cmp)
    win = 0
    cnt = 0


proc fight: void =
    var miniWin = 0
    inc cnt
    for i in 0 ..< n:
        if A[i] > B[i]:
            inc miniWin
        else:
            dec miniWin
    if miniWin > 0:
        inc win


proc main: void =
    while true:
        sort(B, cmp)
        while true:
            fight()
            if not B.nextPermutation: break
        if not A.nextPermutation: break

    echo((win / cnt).formatFloat(ffDecimal, 2))


when isMainModule:
    main()
0