답안 #149250

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

constexpr int INF = 1111111;
int foo(vector<int>& s) {
    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 5 ms 384 KB Output is correct
4 Correct 7 ms 504 KB Output is correct
5 Correct 60 ms 3328 KB Output is correct
6 Correct 12 ms 3328 KB Output is correct
7 Correct 13 ms 3328 KB Output is correct
8 Correct 63 ms 3448 KB Output is correct
9 Correct 62 ms 3328 KB Output is correct
10 Correct 15 ms 3328 KB Output is correct
11 Correct 5 ms 384 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 5 ms 384 KB Output is correct
4 Correct 7 ms 504 KB Output is correct
5 Correct 60 ms 3328 KB Output is correct
6 Correct 12 ms 3328 KB Output is correct
7 Correct 13 ms 3328 KB Output is correct
8 Correct 63 ms 3448 KB Output is correct
9 Correct 62 ms 3328 KB Output is correct
10 Correct 15 ms 3328 KB Output is correct
11 Correct 13 ms 3328 KB Output is correct
12 Correct 14 ms 3328 KB Output is correct
13 Correct 14 ms 3328 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Incorrect 17 ms 3456 KB Output isn't correct
16 Halted 0 ms 0 KB -