結果

問題 No.910 素数部分列
ユーザー tentententen
提出日時 2020-08-26 20:45:08
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 825 bytes
コンパイル時間 2,291 ms
コンパイル使用メモリ 74,788 KB
実行使用メモリ 43,356 KB
最終ジャッジ日時 2024-04-25 03:45:53
合計ジャッジ時間 11,270 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,132 KB
testcase_01 AC 112 ms
40,968 KB
testcase_02 AC 109 ms
40,992 KB
testcase_03 AC 112 ms
41,196 KB
testcase_04 AC 111 ms
41,176 KB
testcase_05 AC 104 ms
40,112 KB
testcase_06 AC 110 ms
41,204 KB
testcase_07 AC 115 ms
40,212 KB
testcase_08 AC 102 ms
40,036 KB
testcase_09 AC 116 ms
41,132 KB
testcase_10 AC 109 ms
40,848 KB
testcase_11 AC 101 ms
40,284 KB
testcase_12 AC 103 ms
39,992 KB
testcase_13 AC 116 ms
40,920 KB
testcase_14 AC 108 ms
40,976 KB
testcase_15 WA -
testcase_16 AC 112 ms
41,120 KB
testcase_17 AC 104 ms
40,404 KB
testcase_18 AC 101 ms
40,060 KB
testcase_19 AC 112 ms
40,940 KB
testcase_20 WA -
testcase_21 AC 108 ms
40,872 KB
testcase_22 AC 111 ms
41,104 KB
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 AC 180 ms
43,096 KB
testcase_42 WA -
testcase_43 AC 184 ms
43,024 KB
testcase_44 AC 188 ms
43,052 KB
testcase_45 AC 183 ms
43,080 KB
testcase_46 AC 180 ms
43,292 KB
testcase_47 WA -
testcase_48 AC 188 ms
43,024 KB
testcase_49 AC 184 ms
42,904 KB
testcase_50 AC 179 ms
42,888 KB
testcase_51 AC 184 ms
42,968 KB
testcase_52 AC 199 ms
42,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] arr = sc.next().toCharArray();
        int count = 0;
        int one = 0;
        int nine = 0;
        for (char c : arr) {
            if (c == '1') {
                if (nine >= 2) {
                    count++;
                    nine -= 2;
                } else {
                    one++;
                }
            } else if (c == '9') {
                if (one > 0) {
                    count++;
                    one--;
                } else {
                    nine++;
                }
            } else {
                count++;
            }
        }
         count += one / 2;
        System.out.println(count);
    }
}
0