답안 #149303

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
149303 2019-09-01T06:10:58 Z Cafe Maru(#3599, bryan, pps789, kazel) HicCup (FXCUP4_hiccup) C++17
100 / 100
66 ms 3584 KB
#include "hiccup.h"
#include<bits/stdc++.h>
using namespace std;

constexpr int INF = 1111111;
int foo(vector<int>& s) {
    if (s.back() != 0) return -1;
    s.pop_back();
    int ret = INF;
    int ce = 0, cc = 0;
    for(int x : s) {
        ce += x;
        cc++;
        s.pop_back();
        ret = min(ret, ce/cc);
    }
    return ret;
}

int HicCup(std::string S) {
	int N = S.size();
    int ans = INF;
    vector<vector<int> > st;
    st.push_back(vector<int>(1,0));
    for(int i=N-1;i>=0;i--) {
        if (S[i] == 'H') {
            vector<int> c = move(st.back());
            st.pop_back();
            if (st.empty()) return -1;
            int t = foo(c);
            ans = min(ans, t);
        } else if (S[i] == 'C') {
            st.back().push_back(0);
            st.push_back(vector<int>(1,0));
        } else {
            st.back().back()++;
        }
    }
    vector<int> c = move(st.back());
    st.pop_back();
    if (!st.empty()) return -1;
    int t = foo(c);
    ans = min(ans, t);

    if(ans == INF) ans = 0;
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 9 ms 512 KB Output is correct
5 Correct 60 ms 3328 KB Output is correct
6 Correct 13 ms 3200 KB Output is correct
7 Correct 13 ms 3200 KB Output is correct
8 Correct 66 ms 3328 KB Output is correct
9 Correct 64 ms 3328 KB Output is correct
10 Correct 13 ms 3328 KB Output is correct
11 Correct 5 ms 128 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 9 ms 512 KB Output is correct
5 Correct 60 ms 3328 KB Output is correct
6 Correct 13 ms 3200 KB Output is correct
7 Correct 13 ms 3200 KB Output is correct
8 Correct 66 ms 3328 KB Output is correct
9 Correct 64 ms 3328 KB Output is correct
10 Correct 13 ms 3328 KB Output is correct
11 Correct 15 ms 3328 KB Output is correct
12 Correct 15 ms 3328 KB Output is correct
13 Correct 15 ms 3328 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 16 ms 3456 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 128 KB Output is correct
18 Correct 7 ms 640 KB Output is correct
19 Correct 17 ms 3328 KB Output is correct
20 Correct 17 ms 3456 KB Output is correct
21 Correct 17 ms 3328 KB Output is correct
22 Correct 15 ms 3200 KB Output is correct
23 Correct 16 ms 3328 KB Output is correct
24 Correct 18 ms 3584 KB Output is correct
25 Correct 47 ms 3328 KB Output is correct
26 Correct 25 ms 3584 KB Output is correct
27 Correct 16 ms 3328 KB Output is correct
28 Correct 17 ms 3200 KB Output is correct
29 Correct 15 ms 3328 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 6 ms 640 KB Output is correct
33 Correct 5 ms 128 KB Output is correct