# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
150488 | 2019-09-01T08:30:50 Z | 오리버스부릉부릉(#3679, rdd6584, orihehe, phpark) | HicCup (FXCUP4_hiccup) | C++17 | 37 ms | 7536 KB |
#include "hiccup.h" #include <stack> #include <vector> using namespace std; vector<int> ss, ww; int HicCup(std::string S) { if (S[0] == '!') return -1; int N = S.size(); int sp, wp; stack<int> sta; for (int i = 0; i < N; i++) { if (S[i] == '!') { ww.push_back(i); continue; } if (S[i] == 'H') { sta.push(1); } else { if (sta.empty()) return -1; else { sta.pop(); ss.push_back(i); } } } if (!sta.empty()) return -1; int ret = 0; int l = 1, r = 1000000, mid; int sz = ss.size(), wz = ww.size(); while (l <= r) { bool suc = true; mid = (l + r) / 2; sp = wp = 0; for (int v : ss) { while (wp < wz && ww[wp] < v) wp++; if (wp == wz) { suc = false; break; } int cnt = 0; while (wp < wz && cnt < mid) { cnt++; wp++; } if (cnt < mid) { suc = false; break; } } if (suc) { ret = mid; l = mid + 1; } else r = mid - 1; } return ret; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 380 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 6 ms | 640 KB | Output is correct |
5 | Correct | 25 ms | 5492 KB | Output is correct |
6 | Correct | 24 ms | 3328 KB | Output is correct |
7 | Correct | 13 ms | 3328 KB | Output is correct |
8 | Correct | 25 ms | 5492 KB | Output is correct |
9 | Correct | 37 ms | 5492 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 | 380 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 6 ms | 640 KB | Output is correct |
5 | Correct | 25 ms | 5492 KB | Output is correct |
6 | Correct | 24 ms | 3328 KB | Output is correct |
7 | Correct | 13 ms | 3328 KB | Output is correct |
8 | Correct | 25 ms | 5492 KB | Output is correct |
9 | Correct | 37 ms | 5492 KB | Output is correct |
10 | Correct | 14 ms | 3328 KB | Output is correct |
11 | Correct | 16 ms | 4136 KB | Output is correct |
12 | Correct | 16 ms | 5620 KB | Output is correct |
13 | Correct | 13 ms | 3964 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Incorrect | 32 ms | 7536 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |