結果

問題 No.77 レンガのピラミッド
ユーザー mbanmban
提出日時 2017-01-05 19:02:55
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,698 bytes
コンパイル時間 2,127 ms
コンパイル使用メモリ 105,988 KB
実行使用メモリ 25,832 KB
最終ジャッジ日時 2023-08-22 14:43:42
合計ジャッジ時間 4,931 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
21,652 KB
testcase_01 AC 59 ms
19,572 KB
testcase_02 AC 61 ms
21,596 KB
testcase_03 AC 60 ms
21,600 KB
testcase_04 WA -
testcase_05 AC 60 ms
23,540 KB
testcase_06 WA -
testcase_07 AC 61 ms
21,736 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 60 ms
21,652 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 + 49] = 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