結果
問題 | No.145 yukiover |
ユーザー | htensai |
提出日時 | 2020-05-14 16:33:00 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,372 bytes |
コンパイル時間 | 2,327 ms |
コンパイル使用メモリ | 77,320 KB |
実行使用メモリ | 42,792 KB |
最終ジャッジ日時 | 2024-09-15 10:52:39 |
合計ジャッジ時間 | 7,691 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 127 ms
41,008 KB |
testcase_01 | AC | 127 ms
40,964 KB |
testcase_02 | AC | 126 ms
41,212 KB |
testcase_03 | AC | 126 ms
41,248 KB |
testcase_04 | AC | 128 ms
41,148 KB |
testcase_05 | WA | - |
testcase_06 | AC | 129 ms
41,128 KB |
testcase_07 | AC | 124 ms
41,116 KB |
testcase_08 | AC | 113 ms
40,208 KB |
testcase_09 | AC | 117 ms
40,124 KB |
testcase_10 | WA | - |
testcase_11 | AC | 211 ms
42,260 KB |
testcase_12 | WA | - |
testcase_13 | AC | 205 ms
42,300 KB |
testcase_14 | AC | 207 ms
42,280 KB |
testcase_15 | AC | 205 ms
42,228 KB |
testcase_16 | AC | 212 ms
41,988 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 207 ms
42,348 KB |
ソースコード
import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); char[] arr = sc.next().toCharArray(); int total = 0; int[] counts = new int[6]; // y - u - k - for (char c : arr) { if (c > 'y') { total++; } else if (c == 'y') { counts[0]++; } else if (c > 'u') { counts[1]++; } else if (c == 'u') { counts[2]++; } else if (c > 'k') { counts[3]++; } else if (c == 'k') { counts[4]++; } else if (c > 'i') { counts[5]++; } } if (counts[4] > counts[5]) { int sum = counts[4] + counts[5]; counts[4] = sum / 2; counts[5] = sum / 2; } int cnt = Math.min(Math.min(counts[0], counts[2]), Math.min(counts[4], counts[5])); total += cnt; counts[0] -= cnt; counts[2] -= cnt; if (counts[2] > counts[3]) { int sum = counts[2] + counts[3]; counts[2] = sum / 2; counts[3] = sum / 2; } cnt = Math.min(counts[0], Math.min(counts[2], counts[3])); total += cnt; counts[0] -= cnt; if (counts[0] > counts[1]) { int sum = counts[0] + counts[1]; counts[0] = sum / 2; counts[1] = sum / 2; } cnt = Math.min(counts[0], counts[1]); total += cnt; System.out.println(total); } }