답안 #148635

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148635 2019-09-01T04:49:37 Z rkm0959(#3623, jun6873, babo) HicCup (FXCUP4_hiccup) C++17
0 / 100
6 ms 384 KB
#include "hiccup.h"
#include <bits/stdc++.h>
using namespace std;

string s;

bool possible(int k) {
    vector<char> v;

    int left = 0;
    for (char i : s) {
        if (i == 'H') {
            if (left) return false;
            v.push_back(0);
        }
        if ((v.back() == 0 and i == 'H') or (v.back() == 1 and i == 'C') or (v.back() >= 2 and i == '!')) v.back()++;
        else if (v.empty() and i == '!') left++;
        else return false;
        if (v.back() == k+2) v.pop_back();
    }
    return v.empty();
}

int HicCup(std::string S) {
    s = S;
    int l = -1, r = 1000004;

    while (l+1<r) {
        int m = (l+r)/2;
        if (possible(m)) l = m;
        else r = m;
    }
	return l;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Runtime error 6 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Runtime error 6 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -