結果

問題 No.2073 Concon Substrings (Swap Version)
ユーザー tentententen
提出日時 2022-09-20 12:30:23
言語 Java19
(openjdk 21)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 1,756 bytes
コンパイル時間 3,100 ms
コンパイル使用メモリ 74,848 KB
実行使用メモリ 55,708 KB
最終ジャッジ日時 2023-08-23 19:34:18
合計ジャッジ時間 10,448 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
49,224 KB
testcase_01 AC 42 ms
49,780 KB
testcase_02 AC 43 ms
49,148 KB
testcase_03 AC 42 ms
47,140 KB
testcase_04 AC 43 ms
49,236 KB
testcase_05 AC 141 ms
54,892 KB
testcase_06 AC 143 ms
54,544 KB
testcase_07 AC 44 ms
49,360 KB
testcase_08 AC 125 ms
54,416 KB
testcase_09 AC 134 ms
54,416 KB
testcase_10 AC 163 ms
55,204 KB
testcase_11 AC 161 ms
55,020 KB
testcase_12 AC 45 ms
49,360 KB
testcase_13 AC 68 ms
51,164 KB
testcase_14 AC 145 ms
55,120 KB
testcase_15 AC 104 ms
52,360 KB
testcase_16 AC 147 ms
54,708 KB
testcase_17 AC 44 ms
49,416 KB
testcase_18 AC 75 ms
51,456 KB
testcase_19 AC 150 ms
54,788 KB
testcase_20 AC 134 ms
54,556 KB
testcase_21 AC 125 ms
54,472 KB
testcase_22 AC 149 ms
54,916 KB
testcase_23 AC 44 ms
49,328 KB
testcase_24 AC 47 ms
49,196 KB
testcase_25 AC 127 ms
54,828 KB
testcase_26 AC 153 ms
55,708 KB
testcase_27 AC 44 ms
49,368 KB
testcase_28 AC 139 ms
55,304 KB
testcase_29 AC 100 ms
52,344 KB
testcase_30 AC 129 ms
54,604 KB
testcase_31 AC 103 ms
52,740 KB
testcase_32 AC 77 ms
51,452 KB
testcase_33 AC 95 ms
52,220 KB
testcase_34 AC 78 ms
53,076 KB
testcase_35 AC 122 ms
54,528 KB
testcase_36 AC 99 ms
53,268 KB
testcase_37 AC 119 ms
54,264 KB
testcase_38 AC 80 ms
52,136 KB
testcase_39 AC 123 ms
54,560 KB
testcase_40 AC 118 ms
54,260 KB
testcase_41 AC 122 ms
53,980 KB
権限があれば一括ダウンロードができます

ソースコード

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