# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
150698 | | Solo Leveling (#200) | HicCup (FXCUP4_hiccup) | C++17 | | 14 ms | 512 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;
struct item{
int h , c , x;
};
int HicCup(std::string S) {
int N = S.size();
int l = 0 , r = N;
int ansj = -1;
while(l<=r){
int mid = (l);
bool can = true;
stack<item >s;
bool jateve = false;
for(int i = 0 ; i < S.size() ; i ++){
if(S[i] == 'H'){
s.push({0 , 1 , mid});
}
else if(S[i] == 'C'){
jateve = true;
if(s.empty()){
can = false;
break;
}
if(s.top().c == 0){
can = false;
break;
}
s.top().c--;
}
else{
if(s.empty() && !jateve){
can = false;
break;
}
if(!s.empty()){
if(s.top().c == 0)
while(!s.empty() && s.top().c == 0){
if(s.top().x == 0){
s.pop();
}
else{
s.top().x--;
if(s.top().x == 0){
s.pop();
}
break;
}
}
else{
if(!jateve){
can = false;
break;
}
}
}
}
}
while(s.size() && s.top().c == 0 && s.top().x == 0) s.pop();
if(s.size()) can = false;
if(can){
ansj = max(ansj , mid);
}
l++;
}
return ansj;
}
Compilation message (stderr)
hiccup.cpp: In function 'int HicCup(std::__cxx11::string)':
hiccup.cpp:18:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0 ; i < S.size() ; i ++){
~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |