Submission #149629

# Submission time Handle Problem Language Result Execution time Memory
149629 2019-09-01T06:52:21 Z distutpia(#3780, cblimmm, wooks1998) HicCup (FXCUP4_hiccup) C++17
0 / 100
29 ms 4352 KB
#include "hiccup.h"

using namespace std;

bool valid(string S){
	int N = S.size();
	int t1=0, t2=0, t3=0;
	for(int i=0;i<N;i++){
		if (S[i]=='H'){
			t1++;
		}
		else if (S[i]== 'C'){
			t2++;
		}
		else if (S[i]== '!'){
			t3++;
		}
		if (t1<t2){
			return false;
		}
		if (t3!=0 && t2==0){
			return false;
		}
	}
	return true;
}

int HicCup(std::string S) {
	int N = S.size();
	int min = 10000000;
	if (!valid(S)){
		return -1;
	}
	int t2=0,t3=0;
	for(int i=N-1; i>=0; i--){
		if (S[i]== 'C'){
			t2++;
		}
		else if (S[i]== '!'){
			t3++;
		}
		if (t2==0){
			continue;
		}
		if (min>(t3/t2)){
			min = t3/t2;
		}
	}
	return min;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 432 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 27 ms 4224 KB Output is correct
6 Correct 14 ms 4352 KB Output is correct
7 Correct 14 ms 4224 KB Output is correct
8 Correct 29 ms 4352 KB Output is correct
9 Correct 29 ms 4224 KB Output is correct
10 Correct 14 ms 4352 KB Output is correct
11 Incorrect 6 ms 384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 432 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 27 ms 4224 KB Output is correct
6 Correct 14 ms 4352 KB Output is correct
7 Correct 14 ms 4224 KB Output is correct
8 Correct 29 ms 4352 KB Output is correct
9 Correct 29 ms 4224 KB Output is correct
10 Correct 14 ms 4352 KB Output is correct
11 Correct 16 ms 4352 KB Output is correct
12 Correct 17 ms 4096 KB Output is correct
13 Correct 15 ms 4352 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Incorrect 23 ms 4224 KB Output isn't correct
16 Halted 0 ms 0 KB -