# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
149195 | 2019-09-01T05:56:34 Z | 20190901(#3597, tongnamuu, jf297, upple1) | HicCup (FXCUP4_hiccup) | C++17 | 446 ms | 20416 KB |
#include "hiccup.h" #include <vector> using namespace std; bool Check(string str, int mid) { vector<pair<char, int>> stk; int hCnt = 0; int cCnt = 0; bool isMake = false; for (int i = 0; i < str.size(); i++) { if (str[i] == 'H') { stk.push_back({ 'H', -1 }); hCnt++; } else if (str[i] == 'C') { if (hCnt > cCnt) stk.push_back({ 'C', 0 }); else return false; cCnt++; } else { if (stk.back().first == 'H') return false; if (stk.empty() && !isMake) return false; else stk.push_back({ '!', stk.back().second + 1 }); } if (stk.back().second == mid) { for (int i = 0; i < mid + 2; i++) { if (stk.empty()) return false; if (stk.back().first == 'C') cCnt--; else if (stk.back().first == 'H') hCnt--; stk.pop_back(); } isMake = true; } } for (int i = 0; i < stk.size(); i++) { if (stk[i].first != '!') return false; } return true; } int HicCup(string S) { int lo = -1; int hi = (int)S.size(); while (lo + 1 < hi) { int mid = (lo + hi) >> 1; if (Check(S, mid)) { lo = mid; } else { hi = mid; } } return lo; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 384 KB | Output is correct |
2 | Correct | 6 ms | 432 KB | Output is correct |
3 | Correct | 6 ms | 384 KB | Output is correct |
4 | Correct | 19 ms | 1436 KB | Output is correct |
5 | Correct | 446 ms | 20392 KB | Output is correct |
6 | Correct | 16 ms | 4140 KB | Output is correct |
7 | Correct | 15 ms | 4352 KB | Output is correct |
8 | Correct | 429 ms | 20416 KB | Output is correct |
9 | Correct | 422 ms | 20412 KB | Output is correct |
10 | Correct | 14 ms | 4352 KB | Output is correct |
11 | Correct | 5 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 384 KB | Output is correct |
2 | Correct | 6 ms | 432 KB | Output is correct |
3 | Correct | 6 ms | 384 KB | Output is correct |
4 | Correct | 19 ms | 1436 KB | Output is correct |
5 | Correct | 446 ms | 20392 KB | Output is correct |
6 | Correct | 16 ms | 4140 KB | Output is correct |
7 | Correct | 15 ms | 4352 KB | Output is correct |
8 | Correct | 429 ms | 20416 KB | Output is correct |
9 | Correct | 422 ms | 20412 KB | Output is correct |
10 | Correct | 14 ms | 4352 KB | Output is correct |
11 | Correct | 88 ms | 7944 KB | Output is correct |
12 | Correct | 130 ms | 11320 KB | Output is correct |
13 | Correct | 33 ms | 6036 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 26 ms | 4556 KB | Output is correct |
16 | Runtime error | 5 ms | 384 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
17 | Halted | 0 ms | 0 KB | - |