結果
問題 |
No.77 レンガのピラミッド
|
ユーザー |
![]() |
提出日時 | 2017-01-05 18:59:30 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,560 bytes |
コンパイル時間 | 1,036 ms |
コンパイル使用メモリ | 111,308 KB |
実行使用メモリ | 29,448 KB |
最終ジャッジ日時 | 2024-12-17 13:52:23 |
合計ジャッジ時間 | 2,743 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 5 |
other | AC * 3 WA * 17 |
コンパイルメッセージ
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(); for(int i = 1; i <= N; i += 2) { if (Py(i) > sum) { break; } int h = i / 2; for (int j = 0; j <= N - 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 = a[j+k]-q; if (sa > 0) { cnt += sa; } } for(int k = 0; k < j; k++) { cnt += a[k]; } for(int k = j + i; k < N; k++) { cnt += a[k]; } ans = Math.Min(cnt, ans); } } Console.WriteLine(ans); } static int Py(int i) { int r = (i + 1) / 2; return r * r; } }