結果

問題 No.910 素数部分列
ユーザー htensaihtensai
提出日時 2019-12-10 12:28:46
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,052 bytes
コンパイル時間 3,483 ms
コンパイル使用メモリ 71,980 KB
実行使用メモリ 61,248 KB
最終ジャッジ日時 2023-09-06 06:12:59
合計ジャッジ時間 14,646 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
56,140 KB
testcase_01 AC 112 ms
55,740 KB
testcase_02 AC 119 ms
55,932 KB
testcase_03 AC 119 ms
55,760 KB
testcase_04 AC 118 ms
56,048 KB
testcase_05 AC 114 ms
55,832 KB
testcase_06 AC 111 ms
55,408 KB
testcase_07 AC 113 ms
55,608 KB
testcase_08 AC 114 ms
56,004 KB
testcase_09 AC 112 ms
55,560 KB
testcase_10 AC 109 ms
56,000 KB
testcase_11 AC 110 ms
56,204 KB
testcase_12 AC 112 ms
55,540 KB
testcase_13 WA -
testcase_14 AC 111 ms
55,796 KB
testcase_15 WA -
testcase_16 AC 119 ms
55,984 KB
testcase_17 WA -
testcase_18 AC 114 ms
55,780 KB
testcase_19 AC 118 ms
55,844 KB
testcase_20 WA -
testcase_21 AC 118 ms
55,632 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 -
testcase_42 WA -
testcase_43 AC 220 ms
59,244 KB
testcase_44 AC 213 ms
59,176 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 AC 209 ms
59,048 KB
testcase_49 AC 203 ms
58,968 KB
testcase_50 AC 213 ms
59,168 KB
testcase_51 AC 200 ms
58,364 KB
testcase_52 AC 207 ms
59,636 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();
        ArrayList<Integer> list = new ArrayList<>();
        int count = 0;
        int sum1 = 0;
        for (char c : arr) {
            if (c == '3' || c == '5' || c == '7') {
                count++;
            } else {
                if (c == '1') {
                    sum1++;
                }
                list.add(c - '0');
            }
        }
        int length = list.size();
        int sum9 = 0;
        int count9 = 0;
        for (int i = length - 1; i >= 0; i--) {
           if (list.get(i) == 9) {
                sum9++;
            } else {
                if (sum9 > 0) {
                    count9++;
                    sum9--;
                }
            }
        }
        count += count9;
        if (length > 0) {
            count += (sum1 - count9) / 2;
        }
        System.out.println(count);
  }
}
0