結果

問題 No.77 レンガのピラミッド
ユーザー syoken_desukasyoken_desuka
提出日時 2015-02-25 19:17:04
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 61 ms / 5,000 ms
コード長 3,562 bytes
コンパイル時間 2,127 ms
コンパイル使用メモリ 106,272 KB
実行使用メモリ 23,500 KB
最終ジャッジ日時 2023-09-06 04:38:14
合計ジャッジ時間 4,753 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
21,488 KB
testcase_01 AC 59 ms
21,488 KB
testcase_02 AC 59 ms
21,284 KB
testcase_03 AC 59 ms
21,280 KB
testcase_04 AC 58 ms
19,436 KB
testcase_05 AC 61 ms
23,500 KB
testcase_06 AC 60 ms
21,336 KB
testcase_07 AC 59 ms
21,392 KB
testcase_08 AC 59 ms
21,296 KB
testcase_09 AC 59 ms
21,292 KB
testcase_10 AC 60 ms
23,376 KB
testcase_11 AC 59 ms
21,472 KB
testcase_12 AC 59 ms
21,528 KB
testcase_13 AC 60 ms
23,444 KB
testcase_14 AC 60 ms
21,540 KB
testcase_15 AC 60 ms
21,404 KB
testcase_16 AC 61 ms
21,372 KB
testcase_17 AC 59 ms
21,492 KB
testcase_18 AC 59 ms
21,408 KB
testcase_19 AC 59 ms
21,488 KB
testcase_20 AC 60 ms
21,568 KB
testcase_21 AC 60 ms
21,340 KB
testcase_22 AC 59 ms
21,440 KB
testcase_23 AC 58 ms
21,352 KB
testcase_24 AC 59 ms
21,404 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.Generic;
using System.Text;
using sc = Scanner;
using System.Collections;
using System.Linq;


class Program
{
    static void Main(string[] args)
    {
        Solve();

#if DEBUG
        Console.WriteLine("終了するにはなにかキーを押して下さい...");
        Console.ReadKey();
#endif

    }

    static void Solve()
    {
        int n = sc.NextInt();
        int[] a = sc.NextIntArray();
        int sum = a.Sum();
        int size = 0;
        int range = 0;
        int answer = 0;
        int identifiedBrock = 0;
        for (int i = 1; i < 120; i++)//yoyuu wo mitumottoku
        {
            if (i*i > sum)
            {
                size = i - 1;
                range = 2 * size - 1;
                break;
            }
        }
        //size ga kisuu dearukoto wo riyousuru
        for (int i = 0; i < range/2; i++) //yobun na kazu wo kazoeage
        {
            if (i >= a.Length) break;
            answer += Math.Max(0, a[i] - (i + 1));
            identifiedBrock += a[i];
#if DEBUG
            Console.WriteLine(":::" + (i + 1));
            Console.WriteLine(i + ":" + answer);
#endif 
        }
        for (int i = range/2; i < range; i++)
        {
            if (i >= a.Length) break;
            answer += Math.Max(0,a[i] - (size + (range/2-i)));
            identifiedBrock += a[i];
#if DEBUG
            Console.WriteLine(":::" +(size+(range / 2 - i)));
            Console.WriteLine(i+":"+answer);
#endif 
        }
        answer += Math.Max(0, sum - identifiedBrock);
        Console.WriteLine(answer);
#if DEBUG
        Console.WriteLine("local check"); // Visual Studioのローカル変数チェック用
#endif 
    }


 }



public static class Scanner
{
    public static string[] NextStrArray()
    {
        return Console.ReadLine().Split(' ');
    }

    public static long[] NextLongArray()
    {
        string[] s = NextStrArray();
        long[] a = new long[s.Length];
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = long.Parse(s[i]);
        }
        return a;
    }
    public static int[] NextIntArray()
    {

        string[] s = NextStrArray();
        int[] a = new int[s.Length];
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = int.Parse(s[i]);
        }
        return a;
    }
    public static int NextInt()
    {
        string tmp = "";
        while (true)
        {
            string readData = char.ConvertFromUtf32(Console.Read());
            if (readData == " " || readData == "\n")
                break;
            tmp += readData;
        }
        return int.Parse(tmp);
    }
    public static double NextDouble()
    {
        string tmp = "";
        while (true)
        {
            string readData = char.ConvertFromUtf32(Console.Read());
            if (readData == " " || readData == "\n")
                break;
            tmp += readData;
        }
        return double.Parse(tmp);
    }
    public static long NextLong()
    {
        string tmp = "";
        while (true)
        {
            string readData = char.ConvertFromUtf32(Console.Read());
            if (readData == " " || readData == "\n")
                break;
            tmp += readData;
        }
        return long.Parse(tmp);
    }
    public static double[] NextDoubleArray()
    {

        string[] s = NextStrArray();
        double[] a = new double[s.Length];
        for (int i = 0; i < a.Length; i++)
        {
            a[i] = double.Parse(s[i]);
        }
        return a;
    }
}
0