// #include "hiccup.h"
using namespace std;
#include "bits/stdc++.h"
bool check(string s){
int ps=0;
for(char c:s){
if(c=='H') ps++;
else ps--;
if(ps<0) return 0;
}
return ps==0;
}
int HicCup(std::string S) {
string t="";
for(char c:S) if(c!='!') t+=c;
if(!check(t)) return -1;
t="";
for(char c:S) if(c!='H') t+=c;
int exc=0, c=0;
if(t.size() && t[0]=='!') return -1;
int ans=1e9;
for(int i=t.size()-1; i>=0; i--){
(t[i]=='!'?exc:c)++;
if(t[i]=='C') ans=min(ans, exc/c);
}
assert(ans!=1e9);
return ans;
}
// int main(){
// string s;
// cin >> s;
// cout << HicCup(s);
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
25 ms |
5320 KB |
Output is correct |
6 |
Correct |
12 ms |
5320 KB |
Output is correct |
7 |
Correct |
13 ms |
5320 KB |
Output is correct |
8 |
Correct |
26 ms |
5272 KB |
Output is correct |
9 |
Correct |
26 ms |
5320 KB |
Output is correct |
10 |
Correct |
13 ms |
5304 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
25 ms |
5320 KB |
Output is correct |
6 |
Correct |
12 ms |
5320 KB |
Output is correct |
7 |
Correct |
13 ms |
5320 KB |
Output is correct |
8 |
Correct |
26 ms |
5272 KB |
Output is correct |
9 |
Correct |
26 ms |
5320 KB |
Output is correct |
10 |
Correct |
13 ms |
5304 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
12 ms |
4840 KB |
Output is correct |
13 |
Correct |
9 ms |
3744 KB |
Output is correct |
14 |
Correct |
6 ms |
3168 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Incorrect |
13 ms |
5300 KB |
Output isn't correct |
17 |
Halted |
0 ms |
0 KB |
- |