結果
問題 | No.193 筒の数式 |
ユーザー |
![]() |
提出日時 | 2015-04-26 22:34:01 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 957 bytes |
コンパイル時間 | 704 ms |
コンパイル使用メモリ | 97,144 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-12 02:38:49 |
合計ジャッジ時間 | 1,383 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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;long 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;long j = 0;while (j < S.length) {long 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;}long acc = t[0].to!long;j = 1;while(j < t.length) {if (t[j] == "+") {acc += t[j+1].to!long;} else if (t[j] == "-") {acc -= t[j+1].to!long;}j += 2;}if (max < acc) max = acc;}writeln(max);}