답안 #148508

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

int HicCup(std::string S) { /// HicHup
	int n = S.size();
	int ans = 0,sum = 0,s2 = 0,minn = 10000000,ch = 0;
	reverse(S.begin(),S.end());
	for(char x : S)
    {
        if(x == 'C') st.push(1);
        else if(x == 'H')
        {
            if(st.empty()) return -1;
            st.pop();
            sum++;
            ch = 0;
            minn = min(minn,s2/sum);
        }
        else
        {
            s2++;
            ch = 1;
        }
    }
    //cout << st.empty() << " " << sum << " " << s2 << " " << minn << '\n';
    if(ch) return -1;
    else if(!st.empty()) return -1;
    else if(s2 == 0) return 0;
	else return min(s2 / sum,minn);
}

Compilation message

hiccup.cpp: In function 'int HicCup(std::__cxx11::string)':
hiccup.cpp:7:6: warning: unused variable 'n' [-Wunused-variable]
  int n = S.size();
      ^
hiccup.cpp:8:6: warning: unused variable 'ans' [-Wunused-variable]
  int ans = 0,sum = 0,s2 = 0,minn = 10000000,ch = 0;
      ^~~
# 결과 실행 시간 메모리 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 512 KB Output is correct
5 Correct 20 ms 3328 KB Output is correct
6 Correct 14 ms 3328 KB Output is correct
7 Correct 13 ms 3328 KB Output is correct
8 Correct 22 ms 3328 KB Output is correct
9 Correct 22 ms 3328 KB Output is correct
10 Correct 14 ms 3328 KB Output is correct
11 Correct 6 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 512 KB Output is correct
5 Correct 20 ms 3328 KB Output is correct
6 Correct 14 ms 3328 KB Output is correct
7 Correct 13 ms 3328 KB Output is correct
8 Correct 22 ms 3328 KB Output is correct
9 Correct 22 ms 3328 KB Output is correct
10 Correct 14 ms 3328 KB Output is correct
11 Correct 14 ms 3328 KB Output is correct
12 Correct 14 ms 3200 KB Output is correct
13 Correct 14 ms 3328 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Incorrect 15 ms 3328 KB Output isn't correct
16 Halted 0 ms 0 KB -