# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
149250 | | Cafe Maru (#200) | HicCup (FXCUP4_hiccup) | C++17 | | 63 ms | 3456 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;
constexpr int INF = 1111111;
int foo(vector<int>& s) {
s.pop_back();
int ret = INF;
int ce = 0, cc = 0;
for(int x : s) {
ce += x;
cc++;
s.pop_back();
ret = min(ret, ce/cc);
}
return ret;
}
int HicCup(std::string S) {
int N = S.size();
int ans = INF;
vector<vector<int> > st;
st.push_back(vector<int>(1,0));
for(int i=N-1;i>=0;i--) {
if (S[i] == 'H') {
vector<int> c = move(st.back());
st.pop_back();
if (st.empty()) return -1;
int t = foo(c);
ans = min(ans, t);
} else if (S[i] == 'C') {
st.back().push_back(0);
st.push_back(vector<int>(1,0));
} else {
st.back().back()++;
}
}
vector<int> c = move(st.back());
st.pop_back();
if (!st.empty()) return -1;
int t = foo(c);
ans = min(ans, t);
if(ans == INF) ans = 0;
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |