結果

問題 No.378 名声値を稼ごう
ユーザー 明智重蔵
提出日時 2016-07-02 20:36:45
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 1,322 bytes
コンパイル時間 894 ms
コンパイル使用メモリ 114,500 KB
実行使用メモリ 25,784 KB
最終ジャッジ日時 2024-06-29 14:03:19
合計ジャッジ時間 1,469 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
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