답안 #150869

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
150869 2019-09-01T09:47:11 Z baikdohyup HicCup (FXCUP4_hiccup) C++17
컴파일 오류
0 ms 0 KB
include "hiccup.h"
include <iostream>
include <vector>

int HicCup(std::string S) { 
int N = S.size(); 
int count = 0; 
int subcount = 0; 
int min = 0; 
int set = 0;
std::vector<char> arr;
std::vector<int> arr2;

for (int i = 0; i < N; i++) {
    if (!arr.empty()) {
        if (arr.back() == 'H' && S[i] == 'C') {
            arr.pop_back();
            i++;
            set++;

            while (S[i] == '!') {
                i++;
                count++;
                subcount++;
            }

            arr2.push_back(subcount);
            subcount = 0;

            i--;

            continue;
        }
        else if (arr.back() == 'H' && S[i] == '!') {
            return -1;
        }
        else if (arr.back() == 'H' && S[i] == 'H') {
            arr.push_back('H');
        }
    }
    else {
        if (S[i] == 'C') {
            return -1;
        }
        else if (S[i] == 'H') {
            arr.push_back('H');
        }
    }

    if (S[i] == '!' && set == 0) {
        return -1;
    }
}

if (!arr.empty()) {
    return -1;
}

int Sum = 0;
int sum = 0;

for (int i = 0; i < arr2.size(); i++) {
    sum += arr2[i];
}

Sum = sum;

while (1) {
    sum = Sum;
    min = arr2.back();
    int debt = 0;
    int can = 1;

    for (int i = 0; i < arr2.size(); i++) {
        if (arr2[i] > min) {
            if (debt > 0) {
                int backup = arr2[i];
                while (debt > 0 && backup > min) {
                    debt--;
                    backup--;
                }

                sum -= backup;
            }
            else {
                sum -= arr2[i];
            }
        }
        else if (arr2[i] == min) {
            sum -= arr2[i];
        }
        else {
            sum -= arr2[i];

            if (min - arr2[i] > sum - ((int)arr2.size() - i - 1) * min) {
                can = 0;
                break;
            }
            else {
                sum -= min - arr2[i];
                debt += min - arr2[i];
            }
        }
    }

    if (can == 1) {
        return min;
    }
    else {
        arr2[arr2.size() - 1]--;
        arr2[arr2.size() - 2]++;
    }
}
}

Compilation message

hiccup.cpp:1:1: error: 'include' does not name a type; did you mean '__has_include'?
 include "hiccup.h"
 ^~~~~~~
 __has_include