結果
問題 | No.161 制限ジャンケン |
ユーザー |
|
提出日時 | 2019-01-23 18:52:17 |
言語 | Nim (2.2.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 651 bytes |
コンパイル時間 | 2,220 ms |
コンパイル使用メモリ | 60,996 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-01 10:37:56 |
合計ジャッジ時間 | 3,108 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
proc getchar_unlocked():char {. importc:"getchar_unlocked",header: "<stdio.h>" .} proc scan(): int = while true: let k = getchar_unlocked() if k < '0': break result = 10 * result + k.ord - '0'.ord var xgcp = @[scan(),scan(),scan()] var ygcp = @[0,0,0] while true: let k = getchar_unlocked() if k < '0': break if k == 'G' : ygcp[0] += 1 if k == 'C' : ygcp[1] += 1 if k == 'P' : ygcp[2] += 1 var ans = 0 for i in 0..<3: let x = i let y = (i+1) mod 3 let d = xgcp[x].min(ygcp[y]) xgcp[x] -= d ygcp[y] -= d ans += d * 3 for i in 0..<3: let d = xgcp[i].min(ygcp[i]) xgcp[i] -= d ygcp[i] -= d ans += d echo ans