結果
| 問題 | No.708 (+ー)の式 |
| コンテスト | |
| ユーザー |
aporo_eeic
|
| 提出日時 | 2018-07-06 01:44:55 |
| 言語 | Python3 (3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 27 ms / 2,000 ms |
| + 44µs | |
| コード長 | 409 bytes |
| 記録 | |
| コンパイル時間 | 56 ms |
| コンパイル使用メモリ | 14,720 KB |
| 実行使用メモリ | 11,392 KB |
| 最終ジャッジ日時 | 2026-10-15 00:22:12 |
| 合計ジャッジ時間 | 1,807 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
data = input().strip()
calc_flag = [1]
ans = [0]
for c in data:
if(c == "("):
ans.append(0)
calc_flag.append(1)
elif(c == ")"):
tmp = ans[-1]
ans.pop()
calc_flag.pop()
ans[-1] += tmp*calc_flag[-1]
elif(c == "+"):
calc_flag[-1] = 1
elif(c == "-"):
calc_flag[-1] = -1
else:
ans[-1] += calc_flag[-1]*int(c)
print(ans[0])
aporo_eeic