백준 20413번
https://www.acmicpc.net/problem/20413
문제
후기
차근차근 구현만 하면 되는 문제다. 앞에서 부터 다음 달에 해당 등급을 만들 수 있는 선에서
최대한으로 과금 했다고 가정하면서 구현하면 된다.
ex) Silver 등급 기준액이 30만원, Gold 등급 기준액이 60만원일 때, 첫달에 29만원을
과금하고, 둘째 달에 30만원을 과금하면, 최근 2달간 59만원으로 Silver 등급이 유지된다.
나의 풀이
import sys
input = sys.stdin.readline
N = int(input())
s , g, p, d = map(int,input().split())
mvp_li = list(map(str,input().strip()))
#계속 라인에 걸치는 최대 금액을 과금한다고 계산하면 될듯
#최대 얼마나 질렀는가..?
ans_li = [0]
for i in range(len(mvp_li)):
bplus = s - ans_li[-1] -1 # 해당 달 브론즈가 되려고 할 때
splus = g - ans_li[-1] -1 # 해당 달 실버가 되려고 할 때
gplus = p - ans_li[-1] -1 # 해당 달 골드가 되려고 할 때
pplus = d - ans_li[-1] -1 # 해당 달 플래티넘이 되려고 할 때
dplus = d #다이아가 되려고 할 때
if mvp_li[i] == "B":
ans_li.append(bplus)
elif mvp_li[i]== "S":
ans_li.append(splus)
elif mvp_li[i] == "G":
ans_li.append(gplus)
elif mvp_li[i] == "P":
ans_li.append(pplus)
else:
ans_li.append(dplus)
print(sum(ans_li))