# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
148515 | | CHT를 사랑하는 모임 (#200) | HicCup (FXCUP4_hiccup) | C++17 | | 150 ms | 4352 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "hiccup.h"
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 1;
ll cnt, N;
string str;
ll sum = 0;
bool chk(ll x){
bool chk = false;
cnt = 0;
sum = 0;
for(int i=0; i<N; i++){
if(str[i]=='H'){
cnt++;
}else if(str[i]=='C'){
if(cnt==0){
return false;
}
cnt--;
sum += x;
chk = true;
}else{
if(sum!=0){
sum--;
}else{
if(!chk) return false;
}
}
}
if(cnt==0 && sum==0) return true;
return false;
}
int HicCup(string S) {
str = S;
N = S.size();
/*for(int i=0; i<N; i++){
if(S[i]=='H'){
cnt++;
}else if(S[i]=='C'){
if(cnt==0){
return -1;
}
cnt--;
}
}
if(cnt!=0){
return -1;
}*/
int s = 0, e = S.size()-1, m;
while(s<e){
m = (s+e)/2+1;
if(chk((ll)m)){
s = m;
}else{
e = m-1;
}
}
if(!chk(s)){
return -1;
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |