結果

問題 No.77 レンガのピラミッド
ユーザー mbanmban
提出日時 2017-01-05 19:04:06
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 64 ms / 5,000 ms
コード長 1,693 bytes
コンパイル時間 2,064 ms
コンパイル使用メモリ 105,456 KB
実行使用メモリ 23,776 KB
最終ジャッジ日時 2023-08-22 14:43:47
合計ジャッジ時間 4,575 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
23,668 KB
testcase_01 AC 59 ms
23,628 KB
testcase_02 AC 58 ms
21,552 KB
testcase_03 AC 59 ms
23,716 KB
testcase_04 AC 57 ms
19,536 KB
testcase_05 AC 58 ms
23,568 KB
testcase_06 AC 63 ms
21,692 KB
testcase_07 AC 58 ms
23,700 KB
testcase_08 AC 63 ms
21,620 KB
testcase_09 AC 62 ms
19,460 KB
testcase_10 AC 61 ms
21,524 KB
testcase_11 AC 62 ms
23,776 KB
testcase_12 AC 62 ms
21,456 KB
testcase_13 AC 63 ms
23,716 KB
testcase_14 AC 63 ms
21,568 KB
testcase_15 AC 61 ms
21,692 KB
testcase_16 AC 60 ms
21,564 KB
testcase_17 AC 61 ms
21,460 KB
testcase_18 AC 64 ms
21,640 KB
testcase_19 AC 61 ms
21,548 KB
testcase_20 AC 60 ms
21,572 KB
testcase_21 AC 63 ms
21,652 KB
testcase_22 AC 62 ms
23,616 KB
testcase_23 AC 62 ms
23,604 KB
testcase_24 AC 60 ms
21,644 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.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;


class Magatro
{
    static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        int ans = int.MaxValue;
        int sum = a.Sum();
        int[] copy = new int[200];
        for(int i = 0; i < N; i++)
        {
            copy[i] = a[i];
        }
        for(int i = 1; i <= 199; i += 2)
        {
            if (Py(i) > sum)
            {
                break;
            }
            int h = i / 2;
            for (int j = 0; j <= 199 - i; j++)
            {
                int cnt = 0;
                for(int k = 0; k < i; k++)
                {
                    int q;
                    if (k <= i / 2)
                    {
                        q = k + 1;
                    }
                    else
                    {
                        q = i - k;
                    }
                    int sa =  copy[j+k]-q;
                    if (sa > 0)
                    {
                        cnt += sa;
                    }
                }
                for(int k = 0; k < j; k++)
                {
                    cnt += copy[k];
                }
                for(int k = j + i; k < 199; k++)
                {
                    cnt += copy[k];
                }
                ans = Math.Min(cnt, ans);
            }
        }
        Console.WriteLine(ans);
    }
    static int Py(int i)
    {
        int r = (i + 1) / 2;
        return r * r;
    }
}
0