# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
136956 | ksmzzang2003 | 스탬프 수집 (JOI16_ho_t2) | C++14 | 11 ms | 2212 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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');
for(ll i=N-1; i>=0; i--) rpi[i] = rpi[i+1]+(A[i]=='I');
for(ll i=0; i<N-1; i++) o=max(o, pj[i]*rpi[i+1]);
for(ll i=0;i<N;i++) if(A[i]=='O') o+=pj[i]*rpi[i]; 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);
}
Compilation message (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... |