제출 #150698

#제출 시각아이디문제언어결과실행 시간메모리
150698Solo Leveling (#200)HicCup (FXCUP4_hiccup)C++17
0 / 100
14 ms512 KiB
#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; }

컴파일 시 표준 에러 (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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...