# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
173449 | ahgus89 | JOIOJI (JOI14_joioji) | C++14 | 2 ms | 504 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int n, m, k, ans, mod=1e9+7;
int J[202020], O[202020], I[202020];
bool chk(int x)
{
for(int i=0;i+3*x<=n;i++)
if(J[i+3*x]-J[i]==x&&O[i+3*x]-O[i]==x&&I[i+3*x]-I[i]==x) return 1;
return 0;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
int i, temp=0;
string s;
cin>>n>>s;
for(i=1;i<=n;i++)
{
J[i]=J[i-1];
O[i]=O[i-1];
I[i]=I[i-1];
if(s[i-1]=='J') J[i]++;
if(s[i-1]=='O') O[i]++;
if(s[i-1]=='I') I[i]++;
}
int lo=0, hi=n/3;
while(lo<hi)
{
int mid=lo+hi+1>>1;
if(chk(mid)) lo=mid;
else hi=mid-1;
}
cout<<lo*3;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |