結果

問題 No.193 筒の数式
ユーザー akichiakichi
提出日時 2017-08-23 22:39:09
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 22 ms / 1,000 ms
コード長 983 bytes
コンパイル時間 750 ms
コンパイル使用メモリ 110,244 KB
実行使用メモリ 26,072 KB
最終ジャッジ日時 2024-04-23 13:38:46
合計ジャッジ時間 1,661 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
25,944 KB
testcase_01 AC 19 ms
23,900 KB
testcase_02 AC 19 ms
24,160 KB
testcase_03 AC 19 ms
23,648 KB
testcase_04 AC 20 ms
25,800 KB
testcase_05 AC 20 ms
24,032 KB
testcase_06 AC 20 ms
23,908 KB
testcase_07 AC 21 ms
23,776 KB
testcase_08 AC 20 ms
25,668 KB
testcase_09 AC 21 ms
23,740 KB
testcase_10 AC 20 ms
25,816 KB
testcase_11 AC 20 ms
23,908 KB
testcase_12 AC 20 ms
24,016 KB
testcase_13 AC 19 ms
23,900 KB
testcase_14 AC 20 ms
25,928 KB
testcase_15 AC 22 ms
26,060 KB
testcase_16 AC 21 ms
23,772 KB
testcase_17 AC 21 ms
26,072 KB
testcase_18 AC 20 ms
24,164 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
class Program {
    static void Main() {
        char[] cs = Console.ReadLine().ToCharArray();
        int len = cs.Length;
        int ans = -(int)Math.Pow(10, 11);
        for (int cut = 0; cut < len; cut++) {
            int score = 0, vol = 0, digit = 0;
            for (int i = len - 1; 0 <= i; i--) {
                char c = cs[(cut + i) % len];
                bool p = c == '+', m = c == '-';
                bool pm = p || m;
                if ((i == len - 1 || i == 0) && pm) goto exit;
                if (pm) {
                    if (p) score += vol;
                    else score -= vol;
                    vol = 0;
                    digit = 0;
                } else {
                    vol += (c - 48) * (int)Math.Pow(10, digit);
                    digit++;
                }
                if (i == 0) score += vol;
            }
            if (ans < score) ans = score;
            exit:;
        }
        Console.WriteLine(ans);
    }
}
0