제출 #148461

#제출 시각아이디문제언어결과실행 시간메모리
148461お前はもう死んでいる (#200)HicCup (FXCUP4_hiccup)C++17
0 / 100
23 ms7168 KiB
#include "hiccup.h"

#include <vector>

int HicCup(std::string S) {
	int n = S.size();
	std::vector<int> freq(n + 1, 0);
	int ans = 0;
	int bal = 0;
	for(auto c : S) {
		if(c == '!') {
			if(freq[ans] == 0) {
				return -1;
			} else {
				freq[ans]--;
				freq[ans+1]++;
				if(freq[ans] == 0) {
					ans++;
				}
			}
		} else if(c == 'H') {
			bal++;
		} else {
			if(bal == 0) {
				return -1;
			}
			bal--;
			ans = 0;
			freq[0]++;
		}
	}
	return ans;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…