이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "hiccup.h"
#include <bits/stdc++.h>
using namespace std;
string s;
bool possible(int k) {
vector<int> v;
int H = 0, C = 1;
for (char i : s) {
if (i == 'H') H++, C = 1;
if (i == 'C') {
if (!H or !C) return false;
H--;
if (k) v.push_back(k);
}
if (i == '!') {
C = 0;
if (!v.empty() and !--v.back()) v.pop_back(), C = 1;
}
}
return !H and v.empty();
}
int HicCup(std::string S) {
s = S;
int l = -1, r = 1000004;
while (l+1<r) {
int m = (l+r)/2;
if (possible(m)) l = m;
else r = m;
}
return l;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |