結果
問題 | No.145 yukiover |
ユーザー | Grenache |
提出日時 | 2016-05-23 20:16:37 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 96 ms / 5,000 ms |
コード長 | 3,428 bytes |
コンパイル時間 | 4,182 ms |
コンパイル使用メモリ | 80,300 KB |
実行使用メモリ | 39,528 KB |
最終ジャッジ日時 | 2024-04-16 09:27:06 |
合計ジャッジ時間 | 6,492 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 54 ms
36,920 KB |
testcase_01 | AC | 54 ms
36,596 KB |
testcase_02 | AC | 53 ms
36,940 KB |
testcase_03 | AC | 53 ms
36,900 KB |
testcase_04 | AC | 52 ms
37,116 KB |
testcase_05 | AC | 54 ms
37,064 KB |
testcase_06 | AC | 53 ms
36,596 KB |
testcase_07 | AC | 53 ms
36,940 KB |
testcase_08 | AC | 55 ms
36,972 KB |
testcase_09 | AC | 54 ms
36,784 KB |
testcase_10 | AC | 54 ms
36,656 KB |
testcase_11 | AC | 96 ms
39,288 KB |
testcase_12 | AC | 93 ms
39,116 KB |
testcase_13 | AC | 88 ms
39,264 KB |
testcase_14 | AC | 95 ms
39,284 KB |
testcase_15 | AC | 94 ms
39,272 KB |
testcase_16 | AC | 89 ms
39,436 KB |
testcase_17 | AC | 95 ms
39,304 KB |
testcase_18 | AC | 93 ms
39,088 KB |
testcase_19 | AC | 95 ms
39,528 KB |
testcase_20 | AC | 94 ms
39,364 KB |
testcase_21 | AC | 92 ms
38,820 KB |
testcase_22 | AC | 95 ms
39,316 KB |
testcase_23 | AC | 93 ms
39,216 KB |
ソースコード
import java.io.*; import java.util.*; public class Main_yukicoder145 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); int n = sc.nextInt(); char[] s = sc.next().toCharArray(); n = s.length; int[] cnt = new int[26]; for (int i = 0; i < n; i++) { cnt[s[i] - 'a']++; } int cz = cnt['z' - 'a']; int cy = cnt['y' - 'a']; int cvwx = cnt['v' - 'a'] + cnt['w' - 'a'] + cnt['x' - 'a']; int cu = cnt['u' - 'a']; int clt = cnt['l' - 'a'] + cnt['m' - 'a'] + cnt['n' - 'a'] + cnt['o' - 'a'] + cnt['p' - 'a'] + cnt['q' - 'a'] + cnt['r' - 'a'] + cnt['s' - 'a'] + cnt['t' - 'a']; int ck = cnt['k' - 'a']; int cj = cnt['j' - 'a']; int ci = cnt['i' - 'a']; int cah = cnt['a' - 'a'] + cnt['b' - 'a'] + cnt['c' - 'a'] + cnt['d' - 'a'] + cnt['e' - 'a'] + cnt['f' - 'a'] + cnt['g' - 'a'] + cnt['h' - 'a']; int ret = cz; // ----------------------------------------- int tmp = Math.min(Math.min(Math.min(cy, cu), ck), ci); tmp = Math.min(tmp, cah); ret += tmp; cy -= tmp; cu -= tmp; ck -= tmp; ci -= tmp; cah -= tmp; tmp = Math.min(Math.min(Math.min(cy, cu), ck), ci / 2); ret += tmp; cy -= tmp; cu -= tmp; ck -= tmp; ci -= tmp * 2; // ----------------------------------------- tmp = Math.min(Math.min(cy, cu), ck); tmp = Math.min(tmp, cj); ret += tmp; cy -= tmp; cu -= tmp; ck -= tmp; cj -= tmp; tmp = Math.min(Math.min(cy, cu), ck / 2); ret += tmp; cy -= tmp; cu -= tmp; ck -= tmp * 2; // ----------------------------------------- tmp = Math.min(cy, cu); tmp = Math.min(tmp, clt); ret += tmp; cy -= tmp; cu -= tmp; clt -= tmp; tmp = Math.min(cy, cu / 2); ret += tmp; cy -= tmp; cu -= tmp * 2; // ----------------------------------------- tmp = Math.min(cy, cvwx); ret += tmp; cy -= tmp; cvwx -= tmp; ret += cy / 2; // ----------------------------------------- pr.println(ret); pr.close(); sc.close(); } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator<String> it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { it = Arrays.asList(br.readLine().split(" ")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }