Submission #150283

#TimeUsernameProblemLanguageResultExecution timeMemory
150283오리버스부릉부릉 (#200)HicCup (FXCUP4_hiccup)C++17
24 / 100
20 ms3328 KiB
#include "hiccup.h"
#include <stack>
using namespace std;

int HicCup(std::string S) {
	int N = S.size();
	stack<int> sta;
	for (int i = 0; i < N; i++) {
		if (S[i] == 'H') {
			sta.push(1);
		}
		else {
			if (sta.empty()) return -1;
			else sta.pop();
		}
	}
	if (!sta.empty()) return -1;

	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...