Submission #148470

#TimeUsernameProblemLanguageResultExecution timeMemory
148470お前はもう死んでいる (#200)HicCup (FXCUP4_hiccup)C++17
24 / 100
23 ms7296 KiB
#include "hiccup.h" #include <vector> int HicCup(std::string S) { int n = S.size(); std::vector<int> freq(n + 1, 0); int ans = 0; int bal = 0; for(auto c : S) { if(c == '!') { if(freq[ans] == 0) { return -1; } else { freq[ans]--; freq[ans+1]++; if(freq[ans] == 0) { ans++; } } } else if(c == 'H') { bal++; } else { if(bal == 0) { return -1; } bal--; ans = 0; freq[0]++; } } if(bal != 0) ans = -1; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...