답안 #149639

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149639 2019-09-01T06:53:16 Z Showing Hands(#3746, hamzqq9, yusufake) HicCup (FXCUP4_hiccup) C++17
24 / 100
23 ms 4352 KB
#include "hiccup.h"
#include<bits/stdc++.h>
#define sz(x) ((int)x.size())
#define pb push_back
#define ppb pop_back
#define ii pair<int,int>
#define st first
#define nd second
#define ll long long
#define N 200005
#define inf 1000000005
#define MOD 1000000007
using namespace std;

int n;
string s;

bool ok(int k) {

	vector<int> gr;
	bool pr=0;

	for(int i=0;i<n;i++) {

		if(s[i]=='H') {

			gr.pb(-1);

		}
		else if(s[i]=='C') {

			if(!sz(gr) || gr.back()!=-1) return 0;

			gr.back()=k;

			if(gr.back()==0) gr.ppb();

			pr=1;

		}
		else {

			if(sz(gr) && gr.back()==-1) return 0;
			if(!sz(gr) && !pr) return 0;

			if(sz(gr)) {

				gr.back()--;

				if(gr.back()==0) gr.ppb();

			}

		}

	}

	return sz(gr)==0;

}

int HicCup(std::string s) {

	n=sz(s);

	::s=s;

	int bas=0,son=1000000;

	while(bas<=son) {

		int orta=(bas+son)>>1;

		if(!ok(orta)) son=orta-1;
		else bas=orta+1;

	}

	return son;

}
# 결과 실행 시간 메모리 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 5 ms 512 KB Output is correct
5 Correct 21 ms 4352 KB Output is correct
6 Correct 15 ms 4352 KB Output is correct
7 Correct 13 ms 4352 KB Output is correct
8 Correct 23 ms 4352 KB Output is correct
9 Correct 23 ms 4312 KB Output is correct
10 Correct 13 ms 4352 KB Output is correct
11 Correct 6 ms 384 KB Output is 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 5 ms 512 KB Output is correct
5 Correct 21 ms 4352 KB Output is correct
6 Correct 15 ms 4352 KB Output is correct
7 Correct 13 ms 4352 KB Output is correct
8 Correct 23 ms 4352 KB Output is correct
9 Correct 23 ms 4312 KB Output is correct
10 Correct 13 ms 4352 KB Output is correct
11 Correct 15 ms 4352 KB Output is correct
12 Correct 13 ms 4160 KB Output is correct
13 Correct 18 ms 4352 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 15 ms 4352 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 6 ms 640 KB Output is correct
19 Incorrect 14 ms 4272 KB Output isn't correct
20 Halted 0 ms 0 KB -