답안 #150679

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
150679 2019-09-01T08:48:50 Z 요까할 로뭘 은명팀(#3558, mario05092929, foja001, earthk) HicCup (FXCUP4_hiccup) C++17
24 / 100
32 ms 7424 KB
#include "hiccup.h"
#include <bits/stdc++.h>
using namespace std;
stack <int> st;
int sum[1000005];

int HicCup(string s) { /// HicHup
	int n = s.size();
	stack <int> l;
	vector <int> hc;
	for(int i = 0;i < n;i++) if(s[i] == '!') l.push(i);
	for(int i = 0;i < n;i++)
    {
        if(s[i] == '!') continue;
        if(s[i] == 'H') st.push(1);
        else
        {
            if(st.empty()) return -1;
            hc.push_back(i);
            st.pop();
        }
    }
    if(!st.empty()) return -1;
    int cnt = 0,sum = 0,ans = 10000000,mi = 10000000;
    for(int i = hc.size()-1;i >= 0;i--)
    {
        cnt = 0;
        //cout << hc[i] << " ";
        while(!l.empty()&&l.top() > hc[i]) l.pop(),cnt++;
        sum += cnt;
        //cout << cnt << " ";
        mi = min(mi,sum/((int)hc.size()-i));
        ans = min(ans,mi);
        //cout << ans << " ";
    }
    return ans;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 768 KB Output is correct
5 Correct 29 ms 5492 KB Output is correct
6 Correct 15 ms 3328 KB Output is correct
7 Correct 14 ms 3328 KB Output is correct
8 Correct 28 ms 5492 KB Output is correct
9 Correct 32 ms 5492 KB Output is correct
10 Correct 16 ms 3456 KB Output is correct
11 Correct 7 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 6 ms 768 KB Output is correct
5 Correct 29 ms 5492 KB Output is correct
6 Correct 15 ms 3328 KB Output is correct
7 Correct 14 ms 3328 KB Output is correct
8 Correct 28 ms 5492 KB Output is correct
9 Correct 32 ms 5492 KB Output is correct
10 Correct 16 ms 3456 KB Output is correct
11 Correct 19 ms 4988 KB Output is correct
12 Correct 24 ms 7040 KB Output is correct
13 Correct 24 ms 7424 KB Output is correct
14 Correct 6 ms 472 KB Output is correct
15 Incorrect 25 ms 7424 KB Output isn't correct
16 Halted 0 ms 0 KB -