結果
| 問題 |
No.77 レンガのピラミッド
|
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2017-01-05 19:04:06 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 5,000 ms |
| コード長 | 1,693 bytes |
| コンパイル時間 | 1,569 ms |
| コンパイル使用メモリ | 110,752 KB |
| 実行使用メモリ | 27,396 KB |
| 最終ジャッジ日時 | 2024-12-17 13:52:33 |
| 合計ジャッジ時間 | 2,453 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 20 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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;
}
}
mban