結果
| 問題 | No.222 引き算と足し算 |
| コンテスト | |
| ユーザー |
🍡yurahuna
|
| 提出日時 | 2016-05-04 13:44:16 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 1,000 ms |
| コード長 | 420 bytes |
| 記録 | |
| コンパイル時間 | 239 ms |
| コンパイル使用メモリ | 85,632 KB |
| 実行使用メモリ | 52,352 KB |
| 最終ジャッジ日時 | 2026-05-10 23:40:29 |
| 合計ジャッジ時間 | 2,459 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 |
ソースコード
s = "#" + input()
t = ""
a = []
op = []
for i in range(1, len(s)):
# 数字の直後の符号のみop
if s[i] in ('+', '-') and s[i - 1].isdigit():
op.append(s[i])
a.append(t)
t = ""
else:
t += s[i]
if t != "":
a.append(t)
a = list(map(int, a))
ans = a[0]
for i in range(len(op)):
if op[i] == '+':
ans -= a[i + 1]
else:
ans += a[i + 1]
print(ans)
🍡yurahuna