結果
問題 | No.193 筒の数式 |
ユーザー | AreTrash |
提出日時 | 2016-06-04 00:40:09 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 27 ms / 1,000 ms |
コード長 | 805 bytes |
コンパイル時間 | 986 ms |
コンパイル使用メモリ | 114,328 KB |
実行使用メモリ | 26,856 KB |
最終ジャッジ日時 | 2024-10-08 07:40:20 |
合計ジャッジ時間 | 2,491 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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); } } }