# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
150698 |
2019-09-01T08:49:58 Z |
Solo Leveling (#3786, wzy) |
HicCup (FXCUP4_hiccup) |
C++17 |
|
14 ms |
512 KB |
#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
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 |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Incorrect |
14 ms |
512 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Incorrect |
14 ms |
512 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |