제출 #148791

#제출 시각아이디문제언어결과실행 시간메모리
148791TLEWA맞 (#200)HicCup (FXCUP4_hiccup)C++17
24 / 100
81 ms37760 KiB
#include "hiccup.h"
#include<bits/stdc++.h>
using namespace std;
int HicCup(std::string S) {
    int H=0,C=0,A=0;
    int cnt;
    int N=S.size();
    int c=0;
    priority_queue<int,vector<int>,greater<int> > pq[1001010];
    int flag=0;
    for(int i=0;i<N;i++){
        if(!flag&&S[i]=='H')flag=1;
        if(S[i]=='H'&&i<N-1&&S[i+1]=='!'){
            return -1;
        }
        if(S[i]=='H'){
            H++;
            c++;
        }
        if(!flag&&S[i]=='C'){
            return -1;
        }
        if(S[i]=='C'){
            C++;
            c--;
            if(C>H)return -1;
            pq[c].push(0);
            cnt=0;
        }
        if(!flag&&S[i]=='!'){
            return -1;
        }
        if(flag&&S[i]=='!'){
            int k=pq[c].top();
            pq[c].pop();
            pq[c].push(k+1);
            cnt++;
        }
    }
    int ret=1010101010;
    if(H!=C)return -1;
    for(int i=0;i<N;i++){
        if(!pq[i].empty()){
            ret=min(pq[i].top(),ret);
        }
    }
    return ret;;
}

컴파일 시 표준 에러 (stderr) 메시지

hiccup.cpp: In function 'int HicCup(std::__cxx11::string)':
hiccup.cpp:5:17: warning: unused variable 'A' [-Wunused-variable]
     int H=0,C=0,A=0;
                 ^
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…