# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
136955 | 2019-07-26T16:30:53 Z | ksmzzang2003 | None (JOI16_ho_t2) | C++14 | 2 ms | 380 KB |
#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); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 380 KB | Output is correct |
4 | Correct | 2 ms | 248 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 256 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Incorrect | 2 ms | 256 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 380 KB | Output is correct |
4 | Correct | 2 ms | 248 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 256 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Incorrect | 2 ms | 256 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 380 KB | Output is correct |
4 | Correct | 2 ms | 248 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 2 ms | 256 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Incorrect | 2 ms | 256 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |