結果
問題 | No.193 筒の数式 |
ユーザー |
![]() |
提出日時 | 2015-04-26 22:29:04 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 950 bytes |
コンパイル時間 | 718 ms |
コンパイル使用メモリ | 96,384 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-12 02:38:48 |
合計ジャッジ時間 | 1,616 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 WA * 5 |
ソースコード
import std.array, std.stdio, std.string, std.algorithm, std.conv;void main(){string S = readln.strip;string l = S ~ S;int max = 0;foreach (i; 0..S.length) {string n = l[i..i+S.length];if (n[0] == '-' || n[0] == '+') continue;if (n[$-1] == '-' || n[$-1] == '+') continue;string[] t;int j = 0;while (j < S.length) {int tmp = j;while(tmp < S.length && '0' <= n[tmp] && n[tmp] <= '9') tmp++;t ~= n[j..tmp];if (tmp < S.length - 1)t ~= n[tmp..tmp+1];j = tmp+1;}int acc = t[0].to!int;j = 1;while(j < t.length) {if (t[j] == "+") {acc += t[j+1].to!int;} else if (t[j] == "-") {acc -= t[j+1].to!int;}j += 2;}if (max < acc) max = acc;}writeln(max);}