이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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]++;
}
}
if(bal != 0) ans = -1;
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |