結果
| 問題 |
No.193 筒の数式
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-08-23 22:39:09 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 24 ms / 1,000 ms |
| コード長 | 983 bytes |
| コンパイル時間 | 837 ms |
| コンパイル使用メモリ | 102,400 KB |
| 実行使用メモリ | 18,048 KB |
| 最終ジャッジ日時 | 2024-10-15 13:38:57 |
| 合計ジャッジ時間 | 2,009 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
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);
}
}