# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
148442 | 모현보유국 (#200) | HicCup (FXCUP4_hiccup) | C++17 | 138 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;
stack<int> stk;
string s;
bool chk(int x){
int cnt = 0;
int save = 0;
for(int i=0; i<s.size(); i++){
if(s[i] == 'H') cnt++;
else if(s[i] == 'C'){
if(cnt == 0) return 0;
cnt--;
save += x;
}else if(s[i] == '!' && save > 0) save--;
}
return save == 0;
}
int HicCup(string S) {
s = S;
int n = s.size();
int ans = -1;
int l = 0, r = 1000000;
while(l <= r){
int m = l + r >> 1;
if(chk(m)){
ans = m;
l = m + 1;
}else{
r = m - 1;
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |