# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
150041 | 2019-09-01T07:36:17 Z | 이 대회 미분 되나요?(#3668, wookje, edenooo, jms100300) | HicCup (FXCUP4_hiccup) | C++17 | 43 ms | 8320 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++; } if (S[i] == 'C') { if (!v.empty()) { lv[i] = v.back(); v.pop_back(); } cnt--; } 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 6 ms | 384 KB | Output is correct |
4 | Correct | 7 ms | 640 KB | Output is correct |
5 | Correct | 43 ms | 8192 KB | Output is correct |
6 | Correct | 14 ms | 4352 KB | Output is correct |
7 | Correct | 14 ms | 4352 KB | Output is correct |
8 | Correct | 42 ms | 8192 KB | Output is correct |
9 | Correct | 39 ms | 8320 KB | Output is correct |
10 | Correct | 15 ms | 4352 KB | Output is correct |
11 | Correct | 6 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 6 ms | 384 KB | Output is correct |
4 | Correct | 7 ms | 640 KB | Output is correct |
5 | Correct | 43 ms | 8192 KB | Output is correct |
6 | Correct | 14 ms | 4352 KB | Output is correct |
7 | Correct | 14 ms | 4352 KB | Output is correct |
8 | Correct | 42 ms | 8192 KB | Output is correct |
9 | Correct | 39 ms | 8320 KB | Output is correct |
10 | Correct | 15 ms | 4352 KB | Output is correct |
11 | Correct | 16 ms | 5168 KB | Output is correct |
12 | Correct | 16 ms | 5888 KB | Output is correct |
13 | Correct | 14 ms | 4480 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Incorrect | 30 ms | 8192 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |