# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
148976 | 맞WATLE (#200) | HicCup (FXCUP4_hiccup) | C++17 | 82 ms | 4352 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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int N;
string S;
bool decide(int X)
{
int i, j;
vector<int> ST;
for(i=0; i<N; i++)
{
if(S[i]=='H') ST.push_back(-1);
else if(S[i]=='C')
{
while(!ST.empty() && ST.back()==0) ST.pop_back();
if(ST.empty()) return false;
if(ST.back()!=-1) return false;
else ST.back()=X;
}
else
{
if(ST.empty()) return false;
if(ST.back()==-1) return false;
if(ST.back()>0) ST.back()--;
if(ST.size()>1 && ST[ST.size()-1]==0 && ST[ST.size()-2]>=0) ST.pop_back();
}
}
while(!ST.empty() && ST.back()==0) ST.pop_back();
if(!ST.empty()) return false;
return true;
}
int HicCup(string _S)
{
int i, j;
S=_S; N=S.size();
int lo=-1, hi=N;
while(lo+1<hi)
{
int mid=lo+hi>>1;
if(decide(mid)) lo=mid;
else hi=mid;
}
return lo;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |