結果

問題 No.944 煎っぞ!
ユーザー bluemeganebluemegane
提出日時 2021-05-15 20:46:05
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 62 ms / 3,000 ms
コード長 1,184 bytes
コンパイル時間 4,518 ms
コンパイル使用メモリ 110,484 KB
実行使用メモリ 32,184 KB
最終ジャッジ日時 2024-04-14 10:57:24
合計ジャッジ時間 8,215 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
32,180 KB
testcase_01 AC 59 ms
29,928 KB
testcase_02 AC 59 ms
30,184 KB
testcase_03 AC 58 ms
30,052 KB
testcase_04 AC 60 ms
31,804 KB
testcase_05 AC 58 ms
32,016 KB
testcase_06 AC 59 ms
30,196 KB
testcase_07 AC 60 ms
30,000 KB
testcase_08 AC 62 ms
30,056 KB
testcase_09 AC 59 ms
30,304 KB
testcase_10 AC 33 ms
25,444 KB
testcase_11 AC 40 ms
28,256 KB
testcase_12 AC 36 ms
25,828 KB
testcase_13 AC 29 ms
25,288 KB
testcase_14 AC 39 ms
24,240 KB
testcase_15 AC 37 ms
27,676 KB
testcase_16 AC 29 ms
26,844 KB
testcase_17 AC 30 ms
27,232 KB
testcase_18 AC 39 ms
28,384 KB
testcase_19 AC 38 ms
26,340 KB
testcase_20 AC 60 ms
27,948 KB
testcase_21 AC 61 ms
30,376 KB
testcase_22 AC 59 ms
32,184 KB
testcase_23 AC 59 ms
30,136 KB
testcase_24 AC 60 ms
29,872 KB
testcase_25 AC 60 ms
32,004 KB
testcase_26 AC 59 ms
29,956 KB
testcase_27 AC 60 ms
32,052 KB
testcase_28 AC 29 ms
27,216 KB
testcase_29 AC 29 ms
26,836 KB
testcase_30 AC 61 ms
30,284 KB
testcase_31 AC 60 ms
29,880 KB
testcase_32 AC 59 ms
32,004 KB
testcase_33 AC 61 ms
29,860 KB
testcase_34 AC 62 ms
32,156 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System.Linq;
using System.Collections.Generic;
using System;

public class Hello
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var sum = a.Sum();
        var amax = a.Max();
        var c = new List<int>();
        for (int i = 1; i * i <= sum; i++)
        {
            if (sum % i == 0)
            {
                if (i >= amax) c.Add(i);
                if (sum / i != i && sum / i >= amax) c.Add(sum / i);
            }
        }
        c.Sort();
        var b = new int[n + 1];
        for (int i = 0; i < n; i++)
        {
            b[i + 1] = b[i] + a[i];
        }
        foreach (var x in c)
        {
            if (check(n, b, x)) { Console.WriteLine(sum / x); break; }
        }
    }
    static bool check(int n, int[] b, int t)
    {
        var p = 0;
        var q = p + 1;
        while (p < n)
        {
            var w = b[q] - b[p];
            if (w > t) return false;
            else if (w == t) { p = q; q = p + 1; continue; }
            q++;
        }
        return true;
    }
}
0