답안 #148773

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
148773 2019-09-01T05:05:42 Z TLEWA맞(#3625, H_Squad, sungjune222, str0ct) HicCup (FXCUP4_hiccup) C++17
0 / 100
9 ms 3712 KB
#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[101010];
    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--;
            pq[c].push(0);
            if(C>H)return -1;
            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;;
}

Compilation message

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;
                 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 3584 KB Output is correct
2 Correct 6 ms 3584 KB Output is correct
3 Runtime error 9 ms 3712 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 3584 KB Output is correct
2 Correct 6 ms 3584 KB Output is correct
3 Runtime error 9 ms 3712 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -