# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
149058 | 2019-09-01T05:39:22 Z | 서울대학교 연구공원 944동 삼성전자서울대연구소(#3600, ho94949, dotorya, zigui) | HicCup (FXCUP4_hiccup) | C++17 | 27 ms | 3328 KB |
#include "hiccup.h" #include <stdio.h> #include <algorithm> #include <assert.h> #include <bitset> #include <cmath> #include <complex> #include <deque> #include <functional> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <queue> #include <set> #include <stdlib.h> #include <string.h> #include <string> #include <time.h> #include <unordered_map> #include <unordered_set> #include <vector> #pragma warning(disable:4996) #pragma comment(linker, "/STACK:336777216") using namespace std; #define mp make_pair #define Fi first #define Se second #define pb(x) push_back(x) #define szz(x) ((int)(x).size()) #define rep(i, n) for(int i=0;i<n;i++) #define all(x) (x).begin(), (x).end() #define ldb ldouble typedef tuple<int, int, int> t3; typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ldb; typedef pair <int, int> pii; typedef pair <ll, ll> pll; typedef pair <ll, int> pli; typedef pair <db, db> pdd; int IT_MAX = 1 << 19; const ll MOD = 1000000007; const int INF = 0x3f3f3f3f; const ll LL_INF = 0x3f3f3f3f3f3f3f3f; const db PI = acos(-1); const db ERR = 1e-10; int HicCup(std::string S) { int N = S.size(), i, j; int c = 0; for (int i = 0; i < N; i++) { if (S[i] == 'H') c++; if (S[i] == 'C') c--; if (c < 0) return -1; } if (S[0] == '!' || c != 0) return -1; int st = 0, en = INF, mi, rv = -1; while (st <= en) { mi = (st + en) / 2; vector <ll> Vr; Vr.push_back(0); int i; for (i = 0; i < N; i++) { if (S[i] == 'H') Vr.push_back(0); else if (S[i] == 'C') { if (Vr.back() > 0) break; Vr.pop_back(); Vr.back() += mi; } else Vr.back()--; } if (i >= N && Vr.back() <= 0) { rv = mi; st = mi + 1; } else en = mi - 1; } return rv; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 384 KB | Output is correct |
2 | Correct | 6 ms | 384 KB | Output is correct |
3 | Correct | 6 ms | 384 KB | Output is correct |
4 | Correct | 6 ms | 512 KB | Output is correct |
5 | Correct | 26 ms | 3328 KB | Output is correct |
6 | Correct | 12 ms | 3328 KB | Output is correct |
7 | Correct | 13 ms | 3328 KB | Output is correct |
8 | Correct | 26 ms | 3328 KB | Output is correct |
9 | Correct | 27 ms | 3328 KB | Output is correct |
10 | Correct | 13 ms | 3328 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 | 384 KB | Output is correct |
3 | Correct | 6 ms | 384 KB | Output is correct |
4 | Correct | 6 ms | 512 KB | Output is correct |
5 | Correct | 26 ms | 3328 KB | Output is correct |
6 | Correct | 12 ms | 3328 KB | Output is correct |
7 | Correct | 13 ms | 3328 KB | Output is correct |
8 | Correct | 26 ms | 3328 KB | Output is correct |
9 | Correct | 27 ms | 3328 KB | Output is correct |
10 | Correct | 13 ms | 3328 KB | Output is correct |
11 | Correct | 15 ms | 3328 KB | Output is correct |
12 | Correct | 13 ms | 3200 KB | Output is correct |
13 | Correct | 14 ms | 3328 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Incorrect | 26 ms | 3328 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |