結果

問題 No.161 制限ジャンケン
ユーザー 小指が強い人小指が強い人
提出日時 2015-11-23 14:57:53
言語 Ruby
(3.3.0)
結果
AC  
実行時間 86 ms / 5,000 ms
コード長 365 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 11,480 KB
実行使用メモリ 15,340 KB
最終ジャッジ日時 2023-08-20 04:43:19
合計ジャッジ時間 2,902 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
15,016 KB
testcase_01 AC 84 ms
15,144 KB
testcase_02 AC 83 ms
15,012 KB
testcase_03 AC 85 ms
15,128 KB
testcase_04 AC 84 ms
15,188 KB
testcase_05 AC 84 ms
15,076 KB
testcase_06 AC 84 ms
15,128 KB
testcase_07 AC 85 ms
15,288 KB
testcase_08 AC 85 ms
15,336 KB
testcase_09 AC 83 ms
15,112 KB
testcase_10 AC 84 ms
15,260 KB
testcase_11 AC 83 ms
15,124 KB
testcase_12 AC 84 ms
15,132 KB
testcase_13 AC 86 ms
15,320 KB
testcase_14 AC 84 ms
15,340 KB
testcase_15 AC 81 ms
15,072 KB
testcase_16 AC 83 ms
15,340 KB
testcase_17 AC 79 ms
15,124 KB
testcase_18 AC 79 ms
15,116 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

a = gets.split.map(&:to_i)
b = Array.new(3, 0)
s = gets.strip
s.each_char do |c|
    b[0] += 1 if c == "G"
    b[1] += 1 if c == "C"
    b[2] += 1 if c == "P"
end
point = 0
3.times do |i|
    j = (i + 2) % 3
    w = (a[j] < b[i]) ? a[j] : b[i]
    a[j] -= w
    b[i] -= w
    point += w * 3
end
3.times do |i|
    point += (a[i] < b[i]) ? a[i] : b[i]
end
puts point
0