# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
151590 | 2019-09-03T15:33:10 Z | leduykhongngu | HicCup (FXCUP4_hiccup) | C++17 | 36 ms | 14328 KB |
#include <cstdio> #include <iostream> #include <cstring> #include <stack> #include <cassert> #include <vector> #include <algorithm> using namespace std; string S = ""; int n; int pre[1000005], sum[1000005]; vector<int> End; bool Check(int lim) { int last = S.length() - 1; int cnt = 0; for (int R : End) { cnt += sum[last] - sum[R - 1]; if (cnt < lim) return false; cnt -= lim; last = R; } return true; } int HicCup(std::string tmp) { S = tmp; stack<int> st; if (tmp[0] == '!') return -1; for (int i = 0; i < tmp.length(); ++i) { sum[i] = sum[i-1]; if (S[i] == '!') { if (i > 0 && S[i-1] == 'H') return -1; ++sum[i]; continue; } if (S[i] == 'H') { st.push(i); } else { assert(S[i] == 'C'); if (st.size() == 0) return -1; int L = st.top(); pre[i] = L; st.pop(); End.push_back(i); } } if (st.size()) return -1; reverse(End.begin(), End.end()); int lef = 0, rig = S.length(), ans = -1; while (lef <= rig) { int mid = (lef + rig)/2; if (Check(mid)) { ans = max(ans, mid); lef = mid + 1; } else rig = mid - 1; } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 248 KB | Output is correct |
4 | Correct | 4 ms | 1016 KB | Output is correct |
5 | Correct | 36 ms | 14184 KB | Output is correct |
6 | Correct | 10 ms | 4344 KB | Output is correct |
7 | Correct | 11 ms | 4216 KB | Output is correct |
8 | Correct | 33 ms | 14188 KB | Output is correct |
9 | Correct | 36 ms | 14328 KB | Output is correct |
10 | Correct | 10 ms | 4220 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 248 KB | Output is correct |
4 | Correct | 4 ms | 1016 KB | Output is correct |
5 | Correct | 36 ms | 14184 KB | Output is correct |
6 | Correct | 10 ms | 4344 KB | Output is correct |
7 | Correct | 11 ms | 4216 KB | Output is correct |
8 | Correct | 33 ms | 14188 KB | Output is correct |
9 | Correct | 36 ms | 14328 KB | Output is correct |
10 | Correct | 10 ms | 4220 KB | Output is correct |
11 | Correct | 14 ms | 6260 KB | Output is correct |
12 | Correct | 14 ms | 7288 KB | Output is correct |
13 | Correct | 10 ms | 4728 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 10 ms | 4344 KB | Output is correct |
16 | Correct | 2 ms | 256 KB | Output is correct |
17 | Correct | 2 ms | 380 KB | Output is correct |
18 | Correct | 3 ms | 888 KB | Output is correct |
19 | Correct | 20 ms | 13048 KB | Output is correct |
20 | Incorrect | 21 ms | 13176 KB | Output isn't correct |
21 | Halted | 0 ms | 0 KB | - |