답안 #771403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
771403 2023-07-02T23:46:20 Z gggkik 스탬프 수집 (JOI16_ho_t2) C++14
100 / 100
6 ms 5332 KB
#include <bits/stdc++.h>
using namespace std;
const int MXN = 1e5+5;
long long J[2][MXN], O[2][MXN], I[2][MXN], n;
char A[MXN];
int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    for(int i = 1;i<=n;i++) cin >> A[i];
    for(int i = n;i;i--){
        I[1][i] = I[1][i+1];
        O[1][i] = O[1][i+1];
        J[1][i] = J[1][i+1];
        if(A[i]=='I') I[1][i]++;
        if(A[i]=='O') O[1][i]+=I[1][i];
        if(A[i]=='J') J[1][i]+=O[1][i];
    }
    long long ans = 0;
    for(int i = 0;i<=n;i++){
        J[0][i] = J[0][i-1];
        O[0][i] = O[0][i-1];
        I[0][i] = I[0][i-1];
        if(A[i]=='J') J[0][i]++;
        if(A[i]=='O') O[0][i]+=J[0][i];
        if(A[i]=='I') I[0][i]+=O[0][i];
        ans = max(ans,J[1][1]+max({
            O[1][i+1],
            1LL*J[0][i]*I[1][i+1],
            O[0][i],
        }));
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 456 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 1 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 1 ms 468 KB Output is correct
18 Correct 1 ms 468 KB Output is correct
19 Correct 1 ms 468 KB Output is correct
20 Correct 1 ms 468 KB Output is correct
21 Correct 1 ms 468 KB Output is correct
22 Correct 1 ms 468 KB Output is correct
23 Correct 1 ms 468 KB Output is correct
24 Correct 1 ms 468 KB Output is correct
25 Correct 1 ms 468 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 456 KB Output is correct
28 Correct 1 ms 468 KB Output is correct
29 Correct 1 ms 468 KB Output is correct
30 Correct 1 ms 460 KB Output is correct
31 Correct 3 ms 5180 KB Output is correct
32 Correct 4 ms 5204 KB Output is correct
33 Correct 3 ms 5204 KB Output is correct
34 Correct 4 ms 5204 KB Output is correct
35 Correct 3 ms 5176 KB Output is correct
36 Correct 4 ms 5204 KB Output is correct
37 Correct 4 ms 5108 KB Output is correct
38 Correct 4 ms 5204 KB Output is correct
39 Correct 4 ms 5164 KB Output is correct
40 Correct 6 ms 5332 KB Output is correct
41 Correct 4 ms 5176 KB Output is correct
42 Correct 4 ms 5204 KB Output is correct
43 Correct 4 ms 5160 KB Output is correct
44 Correct 4 ms 5204 KB Output is correct
45 Correct 3 ms 5204 KB Output is correct