結果

問題 No.145 yukiover
ユーザー yuruhiyayuruhiya
提出日時 2021-07-12 17:08:37
言語 Crystal
(1.11.2)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 898 bytes
コンパイル時間 17,236 ms
コンパイル使用メモリ 255,024 KB
実行使用メモリ 4,720 KB
最終ジャッジ日時 2023-09-14 20:39:46
合計ジャッジ時間 18,383 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,392 KB
testcase_01 AC 2 ms
4,420 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 3 ms
4,412 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 3 ms
4,412 KB
testcase_07 AC 2 ms
4,500 KB
testcase_08 AC 2 ms
4,388 KB
testcase_09 AC 3 ms
4,472 KB
testcase_10 AC 2 ms
4,396 KB
testcase_11 AC 7 ms
4,584 KB
testcase_12 AC 10 ms
4,716 KB
testcase_13 AC 10 ms
4,596 KB
testcase_14 AC 9 ms
4,628 KB
testcase_15 AC 8 ms
4,608 KB
testcase_16 AC 8 ms
4,596 KB
testcase_17 AC 10 ms
4,664 KB
testcase_18 AC 9 ms
4,580 KB
testcase_19 AC 10 ms
4,480 KB
testcase_20 AC 9 ms
4,720 KB
testcase_21 AC 10 ms
4,640 KB
testcase_22 AC 9 ms
4,700 KB
testcase_23 AC 9 ms
4,564 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = read_line.to_i
s = read_line
cnt = [s.count('z'), s.count('y'), s.count("v-x"), s.count('u'), s.count("l-t"), s.count('k'), s.count('j'), s.count('i'), s.count("a-h")]

ans = cnt[0]
cnt[0] = 0
ans += cnt.values_at(1, 2).min.tap { |x|
  {1, 2}.each { |i| cnt[i] -= x }
}
ans += cnt.values_at(1, 3, 4).min.tap { |x|
  {1, 3, 4}.each { |i| cnt[i] -= x }
}
ans += cnt.values_at(1, 3, 5, 6).min.tap { |x|
  {1, 3, 5, 6}.each { |i| cnt[i] -= x }
}
ans += cnt.values_at(1, 3, 5, 7, 8).min.tap { |x|
  {1, 3, 5, 7, 8}.each { |i| cnt[i] -= x }
}
ans += {cnt[1], cnt[3], cnt[5], cnt[7]//2}.min.tap { |x|
  {1, 3, 5, 7, 7}.each { |i| cnt[i] -= x }
}
ans += {cnt[1], cnt[3], cnt[5] // 2}.min.tap { |x|
  {1, 3, 5, 5}.each { |i| cnt[i] -= x }
}
ans += {cnt[1], cnt[3] // 2}.min.tap { |x|
  {1, 3, 3}.each { |i| cnt[i] -= x }
}
ans += {cnt[1] // 2}.min.tap { |x|
  {1, 1}.each { |i| cnt[i] -= x }
}
puts ans
0