結果
問題 | No.133 カードゲーム |
ユーザー |
|
提出日時 | 2019-01-19 19:51:07 |
言語 | Nim (2.2.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 680 bytes |
コンパイル時間 | 2,966 ms |
コンパイル使用メモリ | 65,536 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-01 10:23:26 |
合計ジャッジ時間 | 3,966 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 36) Warning: imported and not used: 'math' [UnusedImport] /home/judge/data/code/Main.nim(1, 17) Warning: imported and not used: 'strutils' [UnusedImport]
ソースコード
import sequtils,strutils,algorithm,mathproc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .}proc scan(): int =while true:var k = getchar_unlocked()if k < '0': breakresult = 10 * result + k.ord - '0'.ordlet n = scan()let A = newSeqWith(n,scan()).sorted(cmp)let B = newSeqWith(n,scan()).sorted(cmp)var AX = Avar cnt = 0var win = 0while true:var BX = Bwhile true:cnt += 1var aWin = 0var bWin = 0for i in 0..<n:if AX[i] > BX[i] : aWin += 1if AX[i] < BX[i] : bWin += 1if aWin > bWin : win += 1if not nextPermutation(BX) : breakif not nextPermutation(AX): breakecho win / cnt