| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 136943 | arnold518 | 스탬프 수집 (JOI16_ho_t2) | C++14 | 6 ms | 2168 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 1e5;
int N;
char S[MAXN+10];
ll pj[MAXN+10], pi[MAXN+10], ans;
int main()
{
int i, j;
scanf("%d%s", &N, S+1);
for(i=1; i<=N; i++) pj[i]=pj[i-1]+(S[i]=='J');
for(i=N; i>=1; i--) pi[i]=pi[i+1]+(S[i]=='I');
ll now=0;
for(i=1; i<N; i++) now=max(now, pj[i]*pi[i+1]);
for(i=1; i<=N; i++) if(S[i]=='O') now+=pj[i]*pi[i];
ans=max(ans, now);
now=0;
for(i=1; i<=N; i++) if(S[i]=='O') now+=(pj[i]+1)*pi[i];
ans=max(ans, now);
now=0;
for(i=1; i<=N; i++) if(S[i]=='O') now+=pj[i]*(pi[i]+1);
ans=max(ans, now);
printf("%lld", ans);
}
컴파일 시 표준 에러 (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... | ||||
