Submission #762329

#TimeUsernameProblemLanguageResultExecution timeMemory
762329goodbyehanbyeolHicCup (FXCUP4_hiccup)C++17
0 / 100
1 ms212 KiB
#include "hiccup.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; int n; char str[1000002]; bool able(int x){ vector<int> stk; bool last = 0; /// 마지막이 느낌표 for(int i=1; i<=n; i++){ if(str[i] == 'H') stk.push_back(-1), last = 0; else if(str[i] == 'C'){ if(stk.empty() || stk.back() != -1) return false; stk.back()++; last = (x==0); } else{ if(stk.empty() || stk.back() == -1){ if(last) {} else return false; } else{ stk.back()++; if(stk.back() >= x) stk.pop_back(), last = 1; else last = 0; } } } return true; } int HicCup(string S){ n = S.size(); for(int i=1; i<=n; i++) str[i] = S[i-1]; int L = 0, R = n, ANS = -1; while(L<=R){ int M = (L+R)/2; if(able(M)) ANS = M, L = M+1; else R = M-1; } return ANS; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...