Submission #148476

#TimeUsernameProblemLanguageResultExecution timeMemory
148476잉여로운 고3 (#200)HicCup (FXCUP4_hiccup)C++17
24 / 100
26 ms3376 KiB
#include <bits/stdc++.h> #include "hiccup.h" using namespace std; int n; int HicCup(string S) { int i, s, a, b, ret; n = S.size(); s = 0; for(i=0; i<n; i++){ if(S[i] == 'H') s ++; else if(S[i] == 'C') s --; if(s < 0) return -1; } if(s != 0) return -1; ret = 1e9; a = b = 0; for(i=n-1; i>=0; i--){ if(S[i] == '!') a ++; else if(S[i] == 'C'){ b ++; ret = min(ret, a / b); } } return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...