이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "hiccup.h"
#include <bits/stdc++.h>
using namespace std;
int cnt[1010101];
int HicCup(string s) {
int n = s.size();
int h = 0;
for(int i = 0; i < n; i++) {
if(s[i] == 'H') h++;
if(s[i] == 'C') h--;
if(h < 0) return -1;
}
if(h != 0) return -1;
int H = 0, mini = 0;
for(int i = 0; i < 1010101; i++) cnt[i] = 0;
for(int i = 0; i < n; i++) {
if(s[i] == 'H') H++;
if(s[i] == 'C') H--, cnt[0]++, mini = 0;
if(s[i] == '!' && cnt[mini] > 0) {
cnt[mini]--;
cnt[mini+1]++;
if(cnt[mini] == 0) mini++;
}
}
return mini;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |