Submission #148431

# Submission time Handle Problem Language Result Execution time Memory
148431 2019-09-01T04:22:27 Z rkm0959(#3623, jun6873, babo) HicCup (FXCUP4_hiccup) C++17
24 / 100
185 ms 8460 KB
#include "hiccup.h"
#include <bits/stdc++.h>
using namespace std;

string s;

bool possible(int k) {
    vector<int> v;

    int H = 0;
    for (char i : s) {
        if (i == 'H') H++;
        if (i == 'C') {
            if (!H) return false;
            H--;
            if (k) v.push_back(k);
        }
        if (i == '!') {
            if (!v.empty() and !--v.back()) v.pop_back();
        }
    }
    return !H and v.empty();
}

int HicCup(std::string S) {
    s = S;
    int l = -1, r = 1000004;

    while (l+1<r) {
        int m = (l+r)/2;
        if (possible(m)) l = m;
        else r = m;
    }
	return l;
}
# Verdict Execution time Memory Grader output
1 Correct 6 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 12 ms 808 KB Output is correct
5 Correct 180 ms 8396 KB Output is correct
6 Correct 15 ms 4352 KB Output is correct
7 Correct 14 ms 4352 KB Output is correct
8 Correct 185 ms 8396 KB Output is correct
9 Correct 183 ms 8460 KB Output is correct
10 Correct 14 ms 4352 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 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 12 ms 808 KB Output is correct
5 Correct 180 ms 8396 KB Output is correct
6 Correct 15 ms 4352 KB Output is correct
7 Correct 14 ms 4352 KB Output is correct
8 Correct 185 ms 8396 KB Output is correct
9 Correct 183 ms 8460 KB Output is correct
10 Correct 14 ms 4352 KB Output is correct
11 Correct 47 ms 5088 KB Output is correct
12 Correct 41 ms 4768 KB Output is correct
13 Correct 19 ms 4096 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Incorrect 71 ms 4352 KB Output isn't correct
16 Halted 0 ms 0 KB -