Official
B - 伯爵の金庫 / The Count's Vault Editorial
by
B - 伯爵の金庫 / The Count's Vault Editorial
by
harurun4635
Editorial for printing
問題文の通りに、順番にシミュレーションすればよいです。
これは for などを使うことで実現できます。t は文字列であることに注意してください。
実装例
n, x = map(int, input().split())
for i in range(n):
t, a = input().split()
a = int(a)
if t == "D":
x += a
else:
if x >= a:
x -= a
print(x)
posted:
last update: