제출 #148449

#제출 시각아이디문제언어결과실행 시간메모리
148449모현보유국 (#200)HicCup (FXCUP4_hiccup)C++17
0 / 100
147 ms4472 KiB
#include "hiccup.h" #include <bits/stdc++.h> using namespace std; stack<int> stk; string s; bool chk(int x){ int cnt = 0; int save = 0; for(int i=0; i<s.size(); i++){ if(s[i] == 'H') cnt++; else if(s[i] == 'C'){ if(cnt == 0) return 0; cnt--; save += x; }else if(s[i] == '!' && save > 0) save--; else if(s[i] == '!' && save <= 0) return 0; } return save == 0; } int HicCup(string S) { s = S; int n = s.size(); int ans = -1; int l = 0, r = 1000000; while(l <= r){ int m = l + r >> 1; if(chk(m)){ ans = m; l = m + 1; }else{ r = m - 1; } } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

hiccup.cpp: In function 'bool chk(int)':
hiccup.cpp:11:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0; i<s.size(); i++){
               ~^~~~~~~~~
hiccup.cpp: In function 'int HicCup(std::__cxx11::string)':
hiccup.cpp:30:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int m = l + r >> 1;
           ~~^~~
hiccup.cpp:25:6: warning: unused variable 'n' [-Wunused-variable]
  int n = s.size();
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...