結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー simansiman
提出日時 2022-09-21 02:17:44
言語 Ruby
(3.2.2)
結果
AC  
実行時間 314 ms / 2,000 ms
コード長 388 bytes
コンパイル時間 51 ms
コンパイル使用メモリ 11,288 KB
実行使用メモリ 16,700 KB
最終ジャッジ日時 2023-08-23 19:47:09
合計ジャッジ時間 9,160 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
15,136 KB
testcase_01 AC 78 ms
15,268 KB
testcase_02 AC 80 ms
15,296 KB
testcase_03 AC 79 ms
15,080 KB
testcase_04 AC 82 ms
15,108 KB
testcase_05 AC 314 ms
16,648 KB
testcase_06 AC 309 ms
16,444 KB
testcase_07 AC 81 ms
14,960 KB
testcase_08 AC 227 ms
15,940 KB
testcase_09 AC 259 ms
16,100 KB
testcase_10 AC 305 ms
16,456 KB
testcase_11 AC 309 ms
16,636 KB
testcase_12 AC 79 ms
15,096 KB
testcase_13 AC 102 ms
15,304 KB
testcase_14 AC 274 ms
16,180 KB
testcase_15 AC 146 ms
15,748 KB
testcase_16 AC 296 ms
16,536 KB
testcase_17 AC 78 ms
15,052 KB
testcase_18 AC 102 ms
15,472 KB
testcase_19 AC 284 ms
16,516 KB
testcase_20 AC 232 ms
16,016 KB
testcase_21 AC 206 ms
15,944 KB
testcase_22 AC 297 ms
16,700 KB
testcase_23 AC 82 ms
15,216 KB
testcase_24 AC 88 ms
15,200 KB
testcase_25 AC 220 ms
16,056 KB
testcase_26 AC 293 ms
16,656 KB
testcase_27 AC 78 ms
15,240 KB
testcase_28 AC 257 ms
16,292 KB
testcase_29 AC 136 ms
15,460 KB
testcase_30 AC 220 ms
16,092 KB
testcase_31 AC 147 ms
15,604 KB
testcase_32 AC 110 ms
15,604 KB
testcase_33 AC 120 ms
15,372 KB
testcase_34 AC 115 ms
15,332 KB
testcase_35 AC 190 ms
15,824 KB
testcase_36 AC 123 ms
15,320 KB
testcase_37 AC 180 ms
15,924 KB
testcase_38 AC 114 ms
15,428 KB
testcase_39 AC 198 ms
16,016 KB
testcase_40 AC 184 ms
15,728 KB
testcase_41 AC 199 ms
15,964 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
S = gets.chomp
L = S.size

counter = Array.new(3) { Hash.new(0) }

L.times do |i|
  s = S[i]

  counter[i % 3][s] += 1
end

p1 = [counter[0]['c'], counter[1]['o'], counter[2]['n']].min
p2 = [counter[1]['c'], counter[2]['o'], counter[0]['n']].min
p3 = [counter[2]['c'], counter[0]['o'], counter[1]['n']].min
ans = p1 + p2 + p3

if ans == N && p1 < N
  ans -= 1
end

puts ans
0