답안 #151155

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
151155 2019-09-01T22:14:11 Z kuroni HicCup (FXCUP4_hiccup) C++17
24 / 100
68 ms 4308 KB
#include "hiccup.h"
#include <bits/stdc++.h>
using namespace std;

bool check(string s, int k)
{
	vector<pair<bool, int>> ve;
	bool chk = false;
	for (char &c : s)
		if (c == 'H')
		{
			ve.push_back({false, 0});
			chk = false;
		}
		else if (c == 'C')
		{
			if (ve.empty() || ve.back().first)
				return false;
			ve.back().first = true;
			if (k == 0)
				ve.pop_back();
		}
		else
		{
			if (!ve.empty())
			{
				if (!ve.back().first && !chk)
					return false;
				if (ve.back().first && (++ve.back().second == k))
				{
					chk = true;
					ve.pop_back();
				}
			}
			else if (!chk)
				return false;
		}
	return ve.empty();
}

int HicCup(string s)
{
	int le = 0, ri = s.size();
	while (le <= ri)
	{
		int mi = (le + ri) / 2;
		if (check(s, mi))
			le = mi + 1;
		else
			ri = mi - 1;
	}
	return le - 1;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 18 ms 4256 KB Output is correct
6 Correct 11 ms 4260 KB Output is correct
7 Correct 12 ms 4308 KB Output is correct
8 Correct 18 ms 4260 KB Output is correct
9 Correct 18 ms 4256 KB Output is correct
10 Correct 12 ms 4256 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 18 ms 4256 KB Output is correct
6 Correct 11 ms 4260 KB Output is correct
7 Correct 12 ms 4308 KB Output is correct
8 Correct 18 ms 4260 KB Output is correct
9 Correct 18 ms 4256 KB Output is correct
10 Correct 12 ms 4256 KB Output is correct
11 Correct 11 ms 4260 KB Output is correct
12 Correct 14 ms 4260 KB Output is correct
13 Correct 16 ms 4256 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 12 ms 4256 KB Output is correct
16 Correct 2 ms 256 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 3 ms 632 KB Output is correct
19 Correct 27 ms 4260 KB Output is correct
20 Correct 18 ms 4264 KB Output is correct
21 Correct 42 ms 4260 KB Output is correct
22 Correct 44 ms 4088 KB Output is correct
23 Correct 68 ms 4260 KB Output is correct
24 Correct 18 ms 4260 KB Output is correct
25 Incorrect 12 ms 4260 KB Output isn't correct
26 Halted 0 ms 0 KB -