結果
問題 | No.2073 Concon Substrings (Swap Version) |
ユーザー | tenten |
提出日時 | 2022-09-20 12:30:23 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 165 ms / 2,000 ms |
コード長 | 1,756 bytes |
コンパイル時間 | 2,327 ms |
コンパイル使用メモリ | 78,328 KB |
実行使用メモリ | 54,964 KB |
最終ジャッジ日時 | 2024-06-01 16:57:40 |
合計ジャッジ時間 | 8,293 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 54 ms
50,384 KB |
testcase_01 | AC | 54 ms
50,212 KB |
testcase_02 | AC | 53 ms
50,440 KB |
testcase_03 | AC | 53 ms
50,284 KB |
testcase_04 | AC | 54 ms
50,348 KB |
testcase_05 | AC | 150 ms
54,572 KB |
testcase_06 | AC | 158 ms
54,336 KB |
testcase_07 | AC | 53 ms
50,344 KB |
testcase_08 | AC | 133 ms
54,292 KB |
testcase_09 | AC | 143 ms
54,244 KB |
testcase_10 | AC | 164 ms
54,812 KB |
testcase_11 | AC | 165 ms
54,964 KB |
testcase_12 | AC | 53 ms
49,996 KB |
testcase_13 | AC | 70 ms
50,728 KB |
testcase_14 | AC | 157 ms
54,300 KB |
testcase_15 | AC | 106 ms
52,188 KB |
testcase_16 | AC | 153 ms
54,500 KB |
testcase_17 | AC | 55 ms
50,452 KB |
testcase_18 | AC | 70 ms
50,528 KB |
testcase_19 | AC | 157 ms
54,356 KB |
testcase_20 | AC | 139 ms
53,984 KB |
testcase_21 | AC | 130 ms
54,424 KB |
testcase_22 | AC | 158 ms
54,564 KB |
testcase_23 | AC | 55 ms
50,380 KB |
testcase_24 | AC | 58 ms
50,380 KB |
testcase_25 | AC | 134 ms
54,016 KB |
testcase_26 | AC | 143 ms
54,552 KB |
testcase_27 | AC | 55 ms
50,132 KB |
testcase_28 | AC | 145 ms
54,348 KB |
testcase_29 | AC | 96 ms
52,156 KB |
testcase_30 | AC | 134 ms
54,368 KB |
testcase_31 | AC | 113 ms
52,036 KB |
testcase_32 | AC | 81 ms
51,800 KB |
testcase_33 | AC | 92 ms
52,104 KB |
testcase_34 | AC | 101 ms
52,004 KB |
testcase_35 | AC | 128 ms
54,308 KB |
testcase_36 | AC | 105 ms
51,856 KB |
testcase_37 | AC | 125 ms
54,096 KB |
testcase_38 | AC | 90 ms
51,940 KB |
testcase_39 | AC | 126 ms
54,224 KB |
testcase_40 | AC | 128 ms
53,964 KB |
testcase_41 | AC | 137 ms
54,292 KB |
ソースコード
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); char[] inputs = sc.next().toCharArray(); int[] cCounts = new int[3]; int[] oCounts = new int[3]; int[] nCounts = new int[3]; for (int i = 0; i < n * 3; i++) { if (inputs[i] == 'c') { cCounts[i % 3]++; } else if (inputs[i] == 'o') { oCounts[i % 3]++; } else if (inputs[i] == 'n') { nCounts[i % 3]++; } } int ans = 0; int[] counts = new int[3]; for (int i = 0; i < 3; i++) { counts[i] = Math.min(cCounts[i], Math.min(oCounts[(i + 1) % 3], nCounts[(i + 2) % 3])); ans += counts[i]; } if (ans == n) { if (counts[0] != n) { ans--; } } System.out.println(ans); } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() throws Exception { } public int nextInt() throws Exception { return Integer.parseInt(next()); } public long nextLong() throws Exception { return Long.parseLong(next()); } public double nextDouble() throws Exception { return Double.parseDouble(next()); } public String next() throws Exception { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } return st.nextToken(); } }