# | 제출 시각UTC-0 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
136955 | ksmzzang2003 | 스탬프 수집 (JOI16_ho_t2) | C++14 | 2 ms | 380 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N;
string A;
ll pj[100003],rpi[100003];
ll o,ret=0;
int main() {
cin>>N>>A;
for(ll i=0; i<N; i++) pj[i] = ((i>0)?pj[i-1]:0) +(A[i]=='J');
ll maxv = 0;
for(ll i=N-1; i>=0; i--) rpi[i] = rpi[i+1]+(A[i]=='I');
for(ll i=0;i<N;i++) if(A[i]=='O') o+=pj[i]*rpi[i],maxv=max(maxv,pj[i]*rpi[i]); o+=maxv; ret = max(ret,o);
o=0;
for(ll i=0;i<N;i++) if(A[i]=='O') o+=(pj[i]+1)*rpi[i]; ret = max(ret,o);
o=0;for(ll i=0;i<N;i++) if(A[i]=='O') o+=pj[i]*(rpi[i]+1); ret = max(ret,o);
printf("%lld",ret);
}
컴파일 시 표준 에러 (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... |