Submission #762329

# Submission time Handle Problem Language Result Execution time Memory
762329 2023-06-21T10:21:04 Z goodbyehanbyeol HicCup (FXCUP4_hiccup) C++17
0 / 100
1 ms 212 KB
#include "hiccup.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n;
char str[1000002];

bool able(int x){
    vector<int> stk;
    bool last = 0; /// 마지막이 느낌표
    for(int i=1; i<=n; i++){
        if(str[i] == 'H') stk.push_back(-1), last = 0;
        else if(str[i] == 'C'){
            if(stk.empty() || stk.back() != -1) return false;
            stk.back()++;
            last = (x==0);
        }
        else{
            if(stk.empty() || stk.back() == -1){
                if(last) {}
                else return false;
            }
            else{
                stk.back()++;
                if(stk.back() >= x) stk.pop_back(), last = 1;
                else last = 0;
            }
        }
    }
    return true;
}

int HicCup(string S){
	n = S.size();
	for(int i=1; i<=n; i++) str[i] = S[i-1];
	int L = 0, R = n, ANS = -1;
	while(L<=R){
        int M = (L+R)/2;
        if(able(M)) ANS = M, L = M+1;
        else R = M-1;
	}
	return ANS;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -