이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<cstdio>
#include<algorithm>
std::pair<std::pair<int,int>,int> a[200001];
char s[200002];
int main()
{
int max=0;
int i,j,n;
scanf("%d%s",&n,s+1);
for(i=1;i<=n;i++)
{
a[i].first=a[i-1].first;
if(s[i]=='J')
{
a[i].first.first++;
a[i].first.second++;
}
else if(s[i]=='O')a[i].first.first--;
else a[i].first.second--;
a[i].second=i;
}
std::sort(a,a+n+1);
i=j=0;
while(i<=n)
{
while(j<=n&&a[i].first==a[j].first)j++;
if(max<a[j-1].second-a[i].second)max=a[j-1].second-a[i].second;
i=j;
}
printf("%d",max);
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |