結果

問題 No.378 名声値を稼ごう
ユーザー 明智重蔵明智重蔵
提出日時 2016-07-02 20:36:45
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 57 ms / 2,000 ms
コード長 1,322 bytes
コンパイル時間 3,035 ms
コンパイル使用メモリ 103,380 KB
実行使用メモリ 22,816 KB
最終ジャッジ日時 2023-09-12 00:56:22
合計ジャッジ時間 3,174 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
20,708 KB
testcase_01 AC 54 ms
20,664 KB
testcase_02 AC 57 ms
22,816 KB
testcase_03 AC 55 ms
20,788 KB
testcase_04 AC 56 ms
20,808 KB
testcase_05 AC 56 ms
20,904 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;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("12");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("123456789123456789");
            //31
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        ulong N = ulong.Parse(InputList[0]);

        var MeiseiList = new List<ulong>();
        ulong CurrMeisei = N;
        while (CurrMeisei > 0) {
            MeiseiList.Add(CurrMeisei);
            CurrMeisei /= 2;
        }

        ulong Sum1 = 0;
        MeiseiList.ForEach(X => Sum1 += X);

        ulong MaxDiff = 0;

        ulong RunSum = 0;
        foreach (ulong EachMeisei in MeiseiList) {
            RunSum += EachMeisei;

            ulong Sum2 = RunSum + EachMeisei;
            ulong CurrDiff = Sum2 - Sum1;
            if (MaxDiff < CurrDiff) 
                MaxDiff = CurrDiff;
        }
        Console.WriteLine(MaxDiff);
    }
}
0