# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
50971 | 2018-06-15T10:18:21 Z | model_code | None (JOI16_ho_t2) | C | 4 ms | 1420 KB |
#include <stdio.h> int n; char S[100005]; int Jsum[100005],Isum[100005]; long long max(long long a,long long b){ if(a>b) return a; return b; } int main(){ int i; scanf("%d%s",&n,S); for(i=0;i<n;++i){ Jsum[i+1]=Jsum[i]+(S[i]=='J'?1:0); Isum[i+1]=Isum[i]+(S[i]=='I'?1:0); } long long res_O=0; for(i=1;i<n;++i){ if(res_O<Jsum[i]*(long long)(Isum[n]-Isum[i])){ res_O=Jsum[i]*(long long)(Isum[n]-Isum[i]); } } long long res_J=0,res_I=0; long long ans=0; for(i=0;i<n;++i) if(S[i]=='O'){ res_J+=Isum[n]-Isum[i+1]; res_I+=Jsum[i]; ans+=(Isum[n]-Isum[i+1])*(long long)Jsum[i]; } ans+=max(max(res_O,res_J),res_I); printf("%lld\n",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 476 KB | Output is correct |
3 | Correct | 2 ms | 512 KB | Output is correct |
4 | Correct | 2 ms | 512 KB | Output is correct |
5 | Correct | 2 ms | 576 KB | Output is correct |
6 | Correct | 2 ms | 576 KB | Output is correct |
7 | Correct | 2 ms | 576 KB | Output is correct |
8 | Correct | 2 ms | 576 KB | Output is correct |
9 | Correct | 2 ms | 576 KB | Output is correct |
10 | Correct | 2 ms | 576 KB | Output is correct |
11 | Correct | 2 ms | 576 KB | Output is correct |
12 | Correct | 2 ms | 576 KB | Output is correct |
13 | Correct | 2 ms | 576 KB | Output is correct |
14 | Correct | 2 ms | 576 KB | Output is correct |
15 | Correct | 2 ms | 576 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 476 KB | Output is correct |
3 | Correct | 2 ms | 512 KB | Output is correct |
4 | Correct | 2 ms | 512 KB | Output is correct |
5 | Correct | 2 ms | 576 KB | Output is correct |
6 | Correct | 2 ms | 576 KB | Output is correct |
7 | Correct | 2 ms | 576 KB | Output is correct |
8 | Correct | 2 ms | 576 KB | Output is correct |
9 | Correct | 2 ms | 576 KB | Output is correct |
10 | Correct | 2 ms | 576 KB | Output is correct |
11 | Correct | 2 ms | 576 KB | Output is correct |
12 | Correct | 2 ms | 576 KB | Output is correct |
13 | Correct | 2 ms | 576 KB | Output is correct |
14 | Correct | 2 ms | 576 KB | Output is correct |
15 | Correct | 2 ms | 576 KB | Output is correct |
16 | Correct | 1 ms | 576 KB | Output is correct |
17 | Correct | 2 ms | 576 KB | Output is correct |
18 | Correct | 2 ms | 576 KB | Output is correct |
19 | Correct | 2 ms | 612 KB | Output is correct |
20 | Correct | 2 ms | 612 KB | Output is correct |
21 | Correct | 2 ms | 612 KB | Output is correct |
22 | Correct | 2 ms | 612 KB | Output is correct |
23 | Correct | 2 ms | 612 KB | Output is correct |
24 | Correct | 2 ms | 732 KB | Output is correct |
25 | Correct | 2 ms | 732 KB | Output is correct |
26 | Correct | 2 ms | 732 KB | Output is correct |
27 | Correct | 2 ms | 732 KB | Output is correct |
28 | Correct | 2 ms | 732 KB | Output is correct |
29 | Correct | 2 ms | 732 KB | Output is correct |
30 | Correct | 2 ms | 732 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 476 KB | Output is correct |
3 | Correct | 2 ms | 512 KB | Output is correct |
4 | Correct | 2 ms | 512 KB | Output is correct |
5 | Correct | 2 ms | 576 KB | Output is correct |
6 | Correct | 2 ms | 576 KB | Output is correct |
7 | Correct | 2 ms | 576 KB | Output is correct |
8 | Correct | 2 ms | 576 KB | Output is correct |
9 | Correct | 2 ms | 576 KB | Output is correct |
10 | Correct | 2 ms | 576 KB | Output is correct |
11 | Correct | 2 ms | 576 KB | Output is correct |
12 | Correct | 2 ms | 576 KB | Output is correct |
13 | Correct | 2 ms | 576 KB | Output is correct |
14 | Correct | 2 ms | 576 KB | Output is correct |
15 | Correct | 2 ms | 576 KB | Output is correct |
16 | Correct | 1 ms | 576 KB | Output is correct |
17 | Correct | 2 ms | 576 KB | Output is correct |
18 | Correct | 2 ms | 576 KB | Output is correct |
19 | Correct | 2 ms | 612 KB | Output is correct |
20 | Correct | 2 ms | 612 KB | Output is correct |
21 | Correct | 2 ms | 612 KB | Output is correct |
22 | Correct | 2 ms | 612 KB | Output is correct |
23 | Correct | 2 ms | 612 KB | Output is correct |
24 | Correct | 2 ms | 732 KB | Output is correct |
25 | Correct | 2 ms | 732 KB | Output is correct |
26 | Correct | 2 ms | 732 KB | Output is correct |
27 | Correct | 2 ms | 732 KB | Output is correct |
28 | Correct | 2 ms | 732 KB | Output is correct |
29 | Correct | 2 ms | 732 KB | Output is correct |
30 | Correct | 2 ms | 732 KB | Output is correct |
31 | Correct | 3 ms | 1380 KB | Output is correct |
32 | Correct | 4 ms | 1384 KB | Output is correct |
33 | Correct | 3 ms | 1384 KB | Output is correct |
34 | Correct | 3 ms | 1384 KB | Output is correct |
35 | Correct | 3 ms | 1384 KB | Output is correct |
36 | Correct | 3 ms | 1384 KB | Output is correct |
37 | Correct | 3 ms | 1384 KB | Output is correct |
38 | Correct | 3 ms | 1384 KB | Output is correct |
39 | Correct | 3 ms | 1384 KB | Output is correct |
40 | Correct | 3 ms | 1420 KB | Output is correct |
41 | Correct | 3 ms | 1420 KB | Output is correct |
42 | Correct | 4 ms | 1420 KB | Output is correct |
43 | Correct | 4 ms | 1420 KB | Output is correct |
44 | Correct | 4 ms | 1420 KB | Output is correct |
45 | Correct | 3 ms | 1420 KB | Output is correct |