結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー tentententen
提出日時 2022-09-20 11:28:20
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,581 bytes
コンパイル時間 3,310 ms
コンパイル使用メモリ 73,972 KB
実行使用メモリ 55,948 KB
最終ジャッジ日時 2023-08-23 19:32:37
合計ジャッジ時間 9,583 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,316 KB
testcase_01 AC 44 ms
49,680 KB
testcase_02 AC 44 ms
49,324 KB
testcase_03 AC 44 ms
49,424 KB
testcase_04 AC 44 ms
49,376 KB
testcase_05 AC 145 ms
54,848 KB
testcase_06 AC 153 ms
54,960 KB
testcase_07 AC 44 ms
49,392 KB
testcase_08 AC 126 ms
54,432 KB
testcase_09 AC 136 ms
54,752 KB
testcase_10 AC 155 ms
55,436 KB
testcase_11 AC 157 ms
55,284 KB
testcase_12 AC 45 ms
49,484 KB
testcase_13 AC 68 ms
51,264 KB
testcase_14 AC 150 ms
55,204 KB
testcase_15 AC 107 ms
52,472 KB
testcase_16 AC 150 ms
55,884 KB
testcase_17 AC 45 ms
49,316 KB
testcase_18 AC 76 ms
51,408 KB
testcase_19 AC 150 ms
54,592 KB
testcase_20 AC 130 ms
54,648 KB
testcase_21 AC 126 ms
52,872 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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();
    }
    
}
0