#include "hiccup.h"
#include <bits/stdc++.h>
using namespace std;
int cnt[1010101];
int HicCup(string s) {
int n = s.size();
int h = 0;
for(int i = 0; i < n; i++) {
if(s[i] == 'H') h++;
if(s[i] == 'C') h--;
if(h < 0) return -1;
}
if(h != 0) return -1;
int H = 0, mini = 0;
for(int i = 0; i < 1010101; i++) cnt[i] = 0;
for(int i = 0; i < n; i++) {
if(s[i] == 'H') H++;
if(s[i] == 'C') H--, cnt[0]++, mini = 0;
if(s[i] == '!' && cnt[mini] > 0) {
cnt[mini]--;
cnt[mini+1]++;
if(cnt[mini] == 0) mini++;
}
}
return mini;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
4352 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
9 ms |
4440 KB |
Output is correct |
5 |
Correct |
27 ms |
7296 KB |
Output is correct |
6 |
Correct |
15 ms |
3328 KB |
Output is correct |
7 |
Correct |
13 ms |
3200 KB |
Output is correct |
8 |
Correct |
27 ms |
7296 KB |
Output is correct |
9 |
Correct |
30 ms |
7288 KB |
Output is correct |
10 |
Correct |
13 ms |
3328 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
4352 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
9 ms |
4440 KB |
Output is correct |
5 |
Correct |
27 ms |
7296 KB |
Output is correct |
6 |
Correct |
15 ms |
3328 KB |
Output is correct |
7 |
Correct |
13 ms |
3200 KB |
Output is correct |
8 |
Correct |
27 ms |
7296 KB |
Output is correct |
9 |
Correct |
30 ms |
7288 KB |
Output is correct |
10 |
Correct |
13 ms |
3328 KB |
Output is correct |
11 |
Correct |
14 ms |
3328 KB |
Output is correct |
12 |
Correct |
13 ms |
3328 KB |
Output is correct |
13 |
Correct |
14 ms |
3200 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Incorrect |
22 ms |
7296 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |