답안 #221936

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
221936 2020-04-11T14:14:57 Z mhy908 스탬프 수집 (JOI16_ho_t2) C++14
100 / 100
9 ms 3712 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int n;
char str[100010];
LL J[100010], JO[100010], OI[100010], I[100010], ans, ans2;
int main(){
    scanf("%d %s", &n, str+1);
    for(int i=1; i<=n; i++){
        J[i]=J[i-1], JO[i]=JO[i-1];
        if(str[i]=='J')J[i]++;
        if(str[i]=='O')JO[i]+=J[i];
        if(str[i]=='I')ans+=JO[i];
    }
    for(int i=n; i>=1; i--){
        I[i]=I[i+1], OI[i]=OI[i+1];
        if(str[i]=='I')I[i]++;
        if(str[i]=='O')OI[i]+=I[i];
    }
    for(int i=1; i<=n+1; i++){
        LL tmp=max(max(OI[i], JO[i-1]), J[i-1]*I[i]);
        ans2=max(ans2, tmp);
    }
    printf("%lld", ans+ans2);
}

Compilation message

2016_ho_t2.cpp: In function 'int main()':
2016_ho_t2.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %s", &n, str+1);
     ~~~~~^~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 512 KB Output is correct
18 Correct 5 ms 512 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 512 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 512 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 512 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 512 KB Output is correct
18 Correct 5 ms 512 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 5 ms 384 KB Output is correct
23 Correct 5 ms 384 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 5 ms 384 KB Output is correct
26 Correct 5 ms 512 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 5 ms 512 KB Output is correct
29 Correct 5 ms 384 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 7 ms 3584 KB Output is correct
32 Correct 8 ms 3712 KB Output is correct
33 Correct 8 ms 3712 KB Output is correct
34 Correct 7 ms 3584 KB Output is correct
35 Correct 7 ms 3584 KB Output is correct
36 Correct 8 ms 3584 KB Output is correct
37 Correct 8 ms 3584 KB Output is correct
38 Correct 8 ms 3712 KB Output is correct
39 Correct 9 ms 3584 KB Output is correct
40 Correct 8 ms 3584 KB Output is correct
41 Correct 8 ms 3584 KB Output is correct
42 Correct 8 ms 3584 KB Output is correct
43 Correct 8 ms 3712 KB Output is correct
44 Correct 8 ms 3712 KB Output is correct
45 Correct 7 ms 3584 KB Output is correct