結果
| 問題 |
No.77 レンガのピラミッド
|
| コンテスト | |
| ユーザー |
utmath
|
| 提出日時 | 2014-11-25 23:50:11 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 5,000 ms |
| コード長 | 907 bytes |
| コンパイル時間 | 886 ms |
| コンパイル使用メモリ | 105,728 KB |
| 実行使用メモリ | 19,456 KB |
| 最終ジャッジ日時 | 2025-01-03 02:43:11 |
| 合計ジャッジ時間 | 2,355 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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.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 <= 1111; 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;
}
}
utmath