# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
150115 | 2019-09-01T07:45:02 Z | 이 대회 미분 되나요?(#3668, wookje, edenooo, jms100300) | HicCup (FXCUP4_hiccup) | C++17 | 85 ms | 8192 KB |
#include "hiccup.h" #include<string> #include<vector> #include<algorithm> using namespace std; int N; string s; int lv[1000101]; bool f(int K) { vector<pair<int, int> > v; for (int i = 0; i < s.size(); i++) { if (s[i] == 'C') { while (!v.empty() && v.back().first > lv[i]) return false; v.push_back({ lv[i], 0 }); while (!v.empty() && v.back().second >= K) v.pop_back(); } else if (s[i] == '!') { if (!v.empty()) v.back().second++; while (!v.empty() && v.back().second >= K) v.pop_back(); } } while (!v.empty()) { if (v.back().second < K) return false; v.pop_back(); } return true; } int HicCup(std::string S) { vector<int> v; N = S.size(); s = S; int cnt = 0; for (int i = 0; i < N; i++) { if (S[i] == 'H') { v.push_back(cnt); cnt++; } else if (S[i] == 'C') { if (!v.empty()) { lv[i] = v.back(); v.pop_back(); } cnt--; } else { if (i == 0 || S[i - 1] == 'H') return -1; } if (cnt < 0) return -1; } if (cnt > 0) return -1; int lo = 0, hi = 1000001; for (int i = 0; i < 21; i++) { int mid = lo + hi >> 1; if (f(mid)) lo = mid; else hi = mid; } return lo; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 6 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 7 ms | 640 KB | Output is correct |
5 | Correct | 42 ms | 8192 KB | Output is correct |
6 | Correct | 13 ms | 4352 KB | Output is correct |
7 | Correct | 14 ms | 4292 KB | Output is correct |
8 | Correct | 44 ms | 8192 KB | Output is correct |
9 | Correct | 44 ms | 8192 KB | Output is correct |
10 | Correct | 14 ms | 4224 KB | Output is correct |
11 | Correct | 6 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 384 KB | Output is correct |
2 | Correct | 6 ms | 384 KB | Output is correct |
3 | Correct | 5 ms | 384 KB | Output is correct |
4 | Correct | 7 ms | 640 KB | Output is correct |
5 | Correct | 42 ms | 8192 KB | Output is correct |
6 | Correct | 13 ms | 4352 KB | Output is correct |
7 | Correct | 14 ms | 4292 KB | Output is correct |
8 | Correct | 44 ms | 8192 KB | Output is correct |
9 | Correct | 44 ms | 8192 KB | Output is correct |
10 | Correct | 14 ms | 4224 KB | Output is correct |
11 | Correct | 17 ms | 5120 KB | Output is correct |
12 | Correct | 17 ms | 5760 KB | Output is correct |
13 | Correct | 15 ms | 4480 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 14 ms | 4352 KB | Output is correct |
16 | Correct | 5 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 128 KB | Output is correct |
18 | Correct | 6 ms | 768 KB | Output is correct |
19 | Correct | 42 ms | 8056 KB | Output is correct |
20 | Correct | 31 ms | 8192 KB | Output is correct |
21 | Correct | 65 ms | 5888 KB | Output is correct |
22 | Correct | 58 ms | 4224 KB | Output is correct |
23 | Correct | 85 ms | 4352 KB | Output is correct |
24 | Correct | 27 ms | 8192 KB | Output is correct |
25 | Correct | 39 ms | 8184 KB | Output is correct |
26 | Correct | 27 ms | 8192 KB | Output is correct |
27 | Correct | 68 ms | 6272 KB | Output is correct |
28 | Correct | 84 ms | 4608 KB | Output is correct |
29 | Correct | 81 ms | 4352 KB | Output is correct |
30 | Correct | 6 ms | 380 KB | Output is correct |
31 | Correct | 5 ms | 384 KB | Output is correct |
32 | Correct | 11 ms | 768 KB | Output is correct |
33 | Correct | 6 ms | 384 KB | Output is correct |