# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
148635 | | rkm0959 (#200) | HicCup (FXCUP4_hiccup) | C++17 | | 6 ms | 384 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "hiccup.h"
#include <bits/stdc++.h>
using namespace std;
string s;
bool possible(int k) {
vector<char> v;
int left = 0;
for (char i : s) {
if (i == 'H') {
if (left) return false;
v.push_back(0);
}
if ((v.back() == 0 and i == 'H') or (v.back() == 1 and i == 'C') or (v.back() >= 2 and i == '!')) v.back()++;
else if (v.empty() and i == '!') left++;
else return false;
if (v.back() == k+2) v.pop_back();
}
return 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... |