# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
149353 | bitKOIn (#200) | HicCup (FXCUP4_hiccup) | C++17 | 139 ms | 3328 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "hiccup.h"
int HicCup(std::string S) {
int N = S.size();
//if(N)
int a=0,b=0,c=0,d=0,n=0,m=1000000;
for(int t=0;t<N;t++)
{
if(S[t]=='H') a++;
if(S[t]=='C') b++;
if(S[t]=='!') c++;
if(c&&(a==0||b==0)) return -1;
if(a<b) return -1;
}
if(a!=b||a==0) return -1;
//m=c/a;
for(;n<m;)
{
int h=(n+m)/2+1;
a=b=0;
long long c=0;
for(int t=0;t<N;t++)
{
if(S[t]=='H') a++;
if(S[t]=='C')
{
a--,c+=h;
}
if(S[t]=='!')
{
if(c)
{
c--;
}
//else return -1;
}
}
if(!c)
n=h;
else m=h-1;
qwe:;
}
return n;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |