# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
148574 | 2019-09-01T04:41:25 Z | 모현보유국(#3693, jhnah917, stonejjun03, ahgus89) | HicCup (FXCUP4_hiccup) | C++17 | 28 ms | 4352 KB |
#include "hiccup.h" #include <bits/stdc++.h> using namespace std; stack<int> stk; string s; bool chk(int x){ int stk = 0; int save = 0; for(int i=0; i<s.size(); i++){ if(s[i] == '!'){ save++; continue; } if(s[i] == 'C'){ stk++; save -= x; if(save < 0) return 0; continue; } if(stk <= 0) return 0; else stk--; } return save >= 0; } bool valid(){ int cnt = 0; for(auto i : s){ if(i == 'C') cnt++; else{ if(cnt == 0) return 0; cnt--; } } return cnt == 0; } int HicCup(string S) { reverse(S.begin(), S.end()); s = S; int n = s.size(); if(!valid()){ return -1; } int ans = -1; int l = 0, r = 1000000; while(l <= r){ int m = l + r >> 1; if(chk(m)){ ans = m; l = m + 1; }else{ r = m - 1; } } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 5 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 | 6 ms | 512 KB | Output is correct |
5 | Correct | 27 ms | 4352 KB | Output is correct |
6 | Correct | 15 ms | 4096 KB | Output is correct |
7 | Correct | 15 ms | 4224 KB | Output is correct |
8 | Correct | 28 ms | 4352 KB | Output is correct |
9 | Correct | 27 ms | 4224 KB | Output is correct |
10 | Correct | 15 ms | 4352 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 | 5 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 | 27 ms | 4352 KB | Output is correct |
6 | Correct | 15 ms | 4096 KB | Output is correct |
7 | Correct | 15 ms | 4224 KB | Output is correct |
8 | Correct | 28 ms | 4352 KB | Output is correct |
9 | Correct | 27 ms | 4224 KB | Output is correct |
10 | Correct | 15 ms | 4352 KB | Output is correct |
11 | Correct | 14 ms | 4096 KB | Output is correct |
12 | Correct | 15 ms | 4352 KB | Output is correct |
13 | Correct | 15 ms | 4352 KB | Output is correct |
14 | Correct | 5 ms | 384 KB | Output is correct |
15 | Correct | 14 ms | 4352 KB | Output is correct |
16 | Correct | 6 ms | 384 KB | Output is correct |
17 | Correct | 5 ms | 384 KB | Output is correct |
18 | Correct | 13 ms | 640 KB | Output is correct |
19 | Incorrect | 16 ms | 4352 KB | Output isn't correct |
20 | Halted | 0 ms | 0 KB | - |