제출 #149201

#제출 시각아이디문제언어결과실행 시간메모리
149201샌즈뼈 (#200)HicCup (FXCUP4_hiccup)C++17
0 / 100
6 ms432 KiB
#include "hiccup.h" using namespace std; int arr[500011]={}; int sz; bool check(int k) { int i,v=0;; for (i=sz;i>=1;i--) { if (arr[i]+v<k) return 0; v+=arr[i]-k; } return 1; } int HicCup(std::string S) { int N = S.size(); int st=0,i,sum=0; for (char x:S) { if (x=='H') st++; if (x=='C') { if (!st--) return 1; sz++; } if (x=='!') { arr[sz]++; sum++;} } if (st) return -1; if (arr[0]) return -1; int l=0, r=sum/sz+1,mid; while(l+1<r) { mid=l+r>>1; if (check(mid)) l=mid; else r=mid; } return l; }

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

hiccup.cpp: In function 'int HicCup(std::__cxx11::string)':
hiccup.cpp:37:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
         mid=l+r>>1;
             ~^~
hiccup.cpp:19:6: warning: unused variable 'N' [-Wunused-variable]
  int N = S.size();
      ^
hiccup.cpp:20:11: warning: unused variable 'i' [-Wunused-variable]
  int st=0,i,sum=0;
           ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...