# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
150665 | 2019-09-01T08:48:00 Z | Solo Leveling (#3786, wzy) | HicCup (FXCUP4_hiccup) | C++17 | 6 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-2; int ansj = -1; while(l<=r){ int mid = (l+r)/2; 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 = mid; l = mid +1; } else r = mid - 1; } return ansj; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 384 KB | Output is correct |
2 | Correct | 6 ms | 384 KB | Output is correct |
3 | Correct | 6 ms | 384 KB | Output is correct |
4 | Incorrect | 6 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 | 6 ms | 384 KB | Output is correct |
3 | Correct | 6 ms | 384 KB | Output is correct |
4 | Incorrect | 6 ms | 512 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |