답안 #148461

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148461 2019-09-01T04:28:19 Z お前はもう死んでいる(#3784, kuroni, nvmdava, tfg) HicCup (FXCUP4_hiccup) C++17
0 / 100
23 ms 7168 KB
#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]++;
		}
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 688 KB Output is correct
5 Correct 23 ms 7168 KB Output is correct
6 Correct 15 ms 7168 KB Output is correct
7 Correct 15 ms 7168 KB Output is correct
8 Correct 22 ms 7168 KB Output is correct
9 Correct 22 ms 7168 KB Output is correct
10 Correct 15 ms 7040 KB Output is correct
11 Incorrect 5 ms 384 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 6 ms 688 KB Output is correct
5 Correct 23 ms 7168 KB Output is correct
6 Correct 15 ms 7168 KB Output is correct
7 Correct 15 ms 7168 KB Output is correct
8 Correct 22 ms 7168 KB Output is correct
9 Correct 22 ms 7168 KB Output is correct
10 Correct 15 ms 7040 KB Output is correct
11 Correct 17 ms 7168 KB Output is correct
12 Correct 19 ms 7168 KB Output is correct
13 Correct 16 ms 7036 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Incorrect 23 ms 7168 KB Output isn't correct
16 Halted 0 ms 0 KB -