結果

問題 No.193 筒の数式
ユーザー AreTrashAreTrash
提出日時 2016-06-04 00:40:09
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 28 ms / 1,000 ms
コード長 805 bytes
コンパイル時間 1,004 ms
コンパイル使用メモリ 108,288 KB
実行使用メモリ 18,688 KB
最終ジャッジ日時 2024-04-17 00:12:31
合計ジャッジ時間 2,303 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
18,560 KB
testcase_01 AC 27 ms
18,688 KB
testcase_02 AC 27 ms
18,432 KB
testcase_03 AC 26 ms
18,688 KB
testcase_04 AC 28 ms
18,560 KB
testcase_05 AC 27 ms
18,560 KB
testcase_06 AC 26 ms
18,560 KB
testcase_07 AC 26 ms
18,560 KB
testcase_08 AC 27 ms
18,560 KB
testcase_09 AC 26 ms
18,432 KB
testcase_10 AC 26 ms
18,560 KB
testcase_11 AC 28 ms
18,560 KB
testcase_12 AC 28 ms
18,560 KB
testcase_13 AC 27 ms
18,688 KB
testcase_14 AC 27 ms
18,432 KB
testcase_15 AC 26 ms
18,432 KB
testcase_16 AC 27 ms
18,560 KB
testcase_17 AC 27 ms
18,560 KB
testcase_18 AC 27 ms
18,688 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.Linq;

namespace No193{
    public class Program{
        public static void Main(string[] args){
            var S = Console.ReadLine();

            Func<string, int> calc = str =>{
                var asp = str.Split('+');
                return asp.Sum(s => {
                    var ssp = s.Split('-');
                    return -ssp.Sum(int.Parse) + int.Parse(ssp[0]) * 2;
                });
            };

            var max = int.MinValue;
            for(var i = 0; i < S.Length; i++){
                if(S[0] != '+' && S[0] != '-' && S[S.Length - 1] != '+' && S[S.Length - 1] != '-'){
                    max = Math.Max(max, calc(S));
                }
                S = S.Remove(0, 1) + S[0];
            }

            Console.WriteLine(max);
        }
    }
}
0