Submission #148416

# Submission time Handle Problem Language Result Execution time Memory
148416 2019-09-01T04:20:34 Z rkm0959(#3623, jun6873, babo) HicCup (FXCUP4_hiccup) C++17
24 / 100
160 ms 8396 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 = 100004;

    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 5 ms 384 KB Output is correct
2 Correct 6 ms 256 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 11 ms 804 KB Output is correct
5 Correct 159 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 160 ms 8380 KB Output is correct
9 Correct 158 ms 8392 KB Output is correct
10 Correct 14 ms 4096 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 6 ms 256 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 11 ms 804 KB Output is correct
5 Correct 159 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 160 ms 8380 KB Output is correct
9 Correct 158 ms 8392 KB Output is correct
10 Correct 14 ms 4096 KB Output is correct
11 Correct 42 ms 5216 KB Output is correct
12 Correct 38 ms 4768 KB Output is correct
13 Correct 18 ms 4224 KB Output is correct
14 Correct 5 ms 128 KB Output is correct
15 Incorrect 58 ms 4480 KB Output isn't correct
16 Halted 0 ms 0 KB -