結果

問題 No.193 筒の数式
ユーザー NoNo
提出日時 2015-06-16 15:42:31
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 60 ms / 1,000 ms
コード長 2,162 bytes
コンパイル時間 3,142 ms
コンパイル使用メモリ 108,040 KB
実行使用メモリ 23,612 KB
最終ジャッジ日時 2023-09-21 09:03:57
合計ジャッジ時間 4,325 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
21,540 KB
testcase_01 AC 58 ms
21,540 KB
testcase_02 AC 59 ms
21,600 KB
testcase_03 AC 60 ms
19,620 KB
testcase_04 AC 60 ms
21,588 KB
testcase_05 AC 59 ms
19,488 KB
testcase_06 AC 59 ms
21,488 KB
testcase_07 AC 59 ms
21,652 KB
testcase_08 AC 58 ms
21,592 KB
testcase_09 AC 58 ms
21,600 KB
testcase_10 AC 58 ms
23,540 KB
testcase_11 AC 59 ms
23,612 KB
testcase_12 AC 59 ms
21,540 KB
testcase_13 AC 58 ms
19,540 KB
testcase_14 AC 60 ms
21,536 KB
testcase_15 AC 59 ms
19,352 KB
testcase_16 AC 60 ms
21,680 KB
testcase_17 AC 59 ms
21,668 KB
testcase_18 AC 59 ms
19,484 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.Linq;
using System.Text;
using System.Threading.Tasks;

namespace foryuki
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine().ToList();
            int max = int.MinValue;
            for (int i = 0; i < S.Count(); i++)
            {
                if (char.IsNumber(S[0]) && char.IsNumber(S[S.Count - 1]))
                {
                    max = Math.Max(max, a(S));
                }
                S.Add(S[0]);
                S.RemoveAt(0);
            }
            Console.WriteLine(max);
        }

        static int a(List<char> s)
        {
            int i = 0;
            int re = 0;
            string x = "";
            bool isPlus = true;

            while (true)
            {
                x = "";
                while (char.IsNumber(s[i]))
                {
                    x += s[i];
                    i++;
                    if (i > s.Count - 1)
                    {
                        break;
                    }
                }

                if (isPlus)
                {
                    re += int.Parse(x);
                }
                else
                {
                    re -= int.Parse(x);
                }

                if (i > s.Count - 1)
                {
                    break;
                }

                if (s[i] == '+')
                {
                    isPlus = true;
                }
                else
                {
                    isPlus = false;
                }
                i++;
            }
            return re;
        }

        //-------------------------------------------------------------

        static int[] ConvertStringArrayToIntArray(string[] array)
        {
            return Array.ConvertAll(array, str => int.Parse(str));
        }

        static List<int> ConvertStringArrayToIntList(string[] str)
        {
            var list = new List<int>();
            foreach (var c in str)
            {
                list.Add(int.Parse(c));
            }
            return list;
        }
    }
}
0