Submission #148487

# Submission time Handle Problem Language Result Execution time Memory
148487 2019-09-01T04:32:23 Z 요까할 로뭘 은명팀(#3558, mario05092929, foja001, earthk) HicCup (FXCUP4_hiccup) C++17
24 / 100
21 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;
            if(s2 != 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 if(s2 / sum > minn) return -1;
	else return s2 / sum;
}

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;
      ^~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 128 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 21 ms 3328 KB Output is correct
6 Correct 14 ms 3328 KB Output is correct
7 Correct 14 ms 3328 KB Output is correct
8 Correct 21 ms 3328 KB Output is correct
9 Correct 21 ms 3328 KB Output is correct
10 Correct 14 ms 3328 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 128 KB Output is correct
4 Correct 6 ms 512 KB Output is correct
5 Correct 21 ms 3328 KB Output is correct
6 Correct 14 ms 3328 KB Output is correct
7 Correct 14 ms 3328 KB Output is correct
8 Correct 21 ms 3328 KB Output is correct
9 Correct 21 ms 3328 KB Output is correct
10 Correct 14 ms 3328 KB Output is correct
11 Correct 16 ms 3328 KB Output is correct
12 Correct 14 ms 3328 KB Output is correct
13 Correct 16 ms 3200 KB Output is correct
14 Correct 5 ms 128 KB Output is correct
15 Correct 14 ms 3328 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 6 ms 384 KB Output is correct
18 Correct 6 ms 512 KB Output is correct
19 Incorrect 17 ms 3328 KB Output isn't correct
20 Halted 0 ms 0 KB -