結果

問題 No.77 レンガのピラミッド
ユーザー utmathutmath
提出日時 2014-11-25 23:49:14
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 903 bytes
コンパイル時間 5,223 ms
コンパイル使用メモリ 106,256 KB
実行使用メモリ 23,640 KB
最終ジャッジ日時 2023-08-31 01:15:40
合計ジャッジ時間 4,009 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
21,500 KB
testcase_01 AC 51 ms
21,440 KB
testcase_02 AC 51 ms
21,468 KB
testcase_03 AC 53 ms
23,560 KB
testcase_04 AC 52 ms
21,452 KB
testcase_05 AC 53 ms
21,372 KB
testcase_06 WA -
testcase_07 AC 52 ms
19,484 KB
testcase_08 WA -
testcase_09 AC 52 ms
23,640 KB
testcase_10 AC 52 ms
23,536 KB
testcase_11 AC 51 ms
21,604 KB
testcase_12 AC 51 ms
21,528 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 52 ms
23,496 KB
testcase_16 AC 51 ms
21,516 KB
testcase_17 AC 53 ms
21,536 KB
testcase_18 WA -
testcase_19 AC 50 ms
21,388 KB
testcase_20 AC 53 ms
21,440 KB
testcase_21 AC 53 ms
21,460 KB
testcase_22 AC 50 ms
23,552 KB
testcase_23 AC 49 ms
21,452 KB
testcase_24 AC 50 ms
21,448 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Linq;

public class MyClass
{
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        var array = Array.ConvertAll<string, int>(Console.ReadLine().Split(new char[]{' '}, StringSplitOptions.RemoveEmptyEntries), int.Parse);
        int res = int.MaxValue;
        for (int i = 1; i <= 111; i+=2)
        {
            res = Math.Min(res, Count(i, array));
        }
        Console.WriteLine(res);
    }

    private static int Count(int end, int[] array)
    {
        int sum = array.Sum();
        int tmp = end / 2 + 1;
        if (sum <tmp*tmp)
        {
            return int.MaxValue;
        }
        int res = sum;
        for (int i = 0; i < end; i++)
        {
            res -= Math.Min((i >= array.Length ? 0 : array[i]), Math.Min(i + 1, end - i));
        }//for i
        return res;
    }

}
0