結果

問題 No.944 煎っぞ!
ユーザー htensaihtensai
提出日時 2019-12-09 11:18:32
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,608 bytes
コンパイル時間 2,551 ms
コンパイル使用メモリ 75,172 KB
実行使用メモリ 61,096 KB
最終ジャッジ日時 2023-09-02 23:27:53
合計ジャッジ時間 18,360 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 495 ms
60,848 KB
testcase_01 AC 453 ms
60,232 KB
testcase_02 AC 480 ms
60,688 KB
testcase_03 AC 454 ms
60,700 KB
testcase_04 AC 449 ms
60,468 KB
testcase_05 AC 458 ms
60,644 KB
testcase_06 AC 480 ms
60,344 KB
testcase_07 AC 486 ms
60,552 KB
testcase_08 AC 480 ms
60,328 KB
testcase_09 AC 463 ms
60,580 KB
testcase_10 AC 180 ms
56,604 KB
testcase_11 AC 267 ms
58,300 KB
testcase_12 AC 235 ms
59,504 KB
testcase_13 AC 128 ms
55,868 KB
testcase_14 AC 291 ms
60,000 KB
testcase_15 AC 227 ms
59,420 KB
testcase_16 AC 129 ms
56,076 KB
testcase_17 AC 128 ms
56,112 KB
testcase_18 AC 286 ms
60,344 KB
testcase_19 AC 299 ms
60,368 KB
testcase_20 AC 472 ms
60,908 KB
testcase_21 AC 477 ms
60,748 KB
testcase_22 AC 449 ms
60,508 KB
testcase_23 AC 469 ms
60,588 KB
testcase_24 AC 453 ms
60,472 KB
testcase_25 AC 468 ms
61,096 KB
testcase_26 AC 465 ms
60,632 KB
testcase_27 AC 484 ms
60,652 KB
testcase_28 AC 120 ms
55,924 KB
testcase_29 AC 120 ms
56,080 KB
testcase_30 AC 466 ms
60,552 KB
testcase_31 WA -
testcase_32 AC 449 ms
60,728 KB
testcase_33 AC 489 ms
61,020 KB
testcase_34 AC 495 ms
60,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        int total = 0;
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
            total += arr[i];
        }
        TreeSet<Integer> set = new TreeSet<>();
        for (int i = 2; i <= Math.sqrt(total); i++) {
            if (total % i == 0) {
                set.add(total / i);
                int idx = 0;
                boolean flag = true;
                int cur = 0;
                while (idx < n) {
                    cur += arr[idx];
                    if (cur > i) {
                        flag = false;
                        break;
                    } else if (cur == i) {
                        cur = 0;
                    }
                    idx++;
                }
                if (flag) {
                    System.out.println(total / i);
                    return;
                }
            }
        }
        for (int x : set) {
            int idx = 0;
            boolean flag = true;
            int cur = 0;
            while (idx < n) {
                cur += arr[idx];
                if (cur > x) {
                    flag = false;
                    break;
                } else if (cur == x) {
                    cur = 0;
                }
                idx++;
            }
            if (flag) {
                System.out.println(total / x);
                return;
            }
        }
        System.out.println(1);
    }
}
0