# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
149231 | 샌즈뼈 (#200) | HicCup (FXCUP4_hiccup) | C++17 | 20 ms | 3584 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"
using namespace std;
int arr[500011]={};
int sz;
bool check(int k)
{
int i,v=0;;
for (i=sz;i>=1;i--)
{
if (arr[i]+v<k) return 0;
v+=arr[i]-k;
}
return 1;
}
int HicCup(std::string S) {
int N = S.size();
int st=0,i,sum=0;
for (char x:S)
{
if (x=='H') st++;
if (x=='C')
{
if (!st--) return -1;
sz++;
}
if (x=='!') { arr[sz]++; sum++;}
}
if (st) return -1;
if (arr[0]) return -1;
int l=0, r=sum/sz+1,mid;
while(l+1<r)
{
mid=l+r>>1;
if (check(mid)) l=mid;
else r=mid;
}
return l;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |