結果

問題 No.161 制限ジャンケン
ユーザー むらためむらため
提出日時 2019-01-23 18:52:17
言語 Nim
(2.0.2)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 651 bytes
コンパイル時間 2,438 ms
コンパイル使用メモリ 66,216 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 02:37:46
合計ジャッジ時間 3,609 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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
0