結果

問題 No.77 レンガのピラミッド
ユーザー syoken_desukasyoken_desuka
提出日時 2015-02-25 19:13:28
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 3,402 bytes
コンパイル時間 2,237 ms
コンパイル使用メモリ 102,384 KB
実行使用メモリ 25,508 KB
最終ジャッジ日時 2023-09-06 04:38:09
合計ジャッジ時間 4,988 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
23,468 KB
testcase_01 AC 59 ms
21,288 KB
testcase_02 WA -
testcase_03 AC 59 ms
21,420 KB
testcase_04 AC 59 ms
23,316 KB
testcase_05 AC 58 ms
21,400 KB
testcase_06 AC 59 ms
21,424 KB
testcase_07 WA -
testcase_08 AC 59 ms
23,324 KB
testcase_09 AC 59 ms
23,496 KB
testcase_10 AC 59 ms
21,300 KB
testcase_11 AC 61 ms
23,332 KB
testcase_12 AC 60 ms
23,656 KB
testcase_13 AC 59 ms
25,508 KB
testcase_14 AC 60 ms
21,496 KB
testcase_15 AC 60 ms
21,448 KB
testcase_16 AC 62 ms
23,348 KB
testcase_17 AC 59 ms
21,292 KB
testcase_18 AC 59 ms
23,396 KB
testcase_19 AC 59 ms
21,520 KB
testcase_20 AC 59 ms
23,508 KB
testcase_21 AC 59 ms
23,464 KB
testcase_22 AC 59 ms
21,452 KB
testcase_23 AC 58 ms
21,416 KB
testcase_24 AC 60 ms
21,460 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;
        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));
#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)));
#if DEBUG
            Console.WriteLine(":::" +(size+(range / 2 - i)));
            Console.WriteLine(i+":"+answer);
#endif 
        }

        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