結果
問題 |
No.2073 Concon Substrings (Swap Version)
|
ユーザー |
![]() |
提出日時 | 2022-09-20 11:28:20 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,581 bytes |
コンパイル時間 | 3,703 ms |
コンパイル使用メモリ | 77,816 KB |
実行使用メモリ | 55,400 KB |
最終ジャッジ日時 | 2024-12-22 03:27:04 |
合計ジャッジ時間 | 9,120 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 17 WA * 20 |
ソースコード
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; for (int i = 0; i < 3; i++) { ans += Math.min(cCounts[i], Math.min(oCounts[(i + 1) % 3], nCounts[(i + 2) % 3])); } 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(); } }