답안 #448255

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
448255 2021-07-29T12:40:08 Z JovanB 스탬프 수집 (JOI16_ho_t2) C++17
100 / 100
5 ms 5324 KB
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
ll pre[100005][3];
ll suf[100005][3];
 
int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;
 
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i=1; i<=n; i++){
        pre[i][0] = pre[i-1][0];
        pre[i][1] = pre[i-1][1];
        pre[i][2] = pre[i-1][2];
        if(s[i-1] == 'J'){
            pre[i][0]++;
        }
        else if(s[i-1] == 'O'){
            pre[i][1] += pre[i][0];
        }
        else{
            pre[i][2] += pre[i][1];
        }
    }
    for(int i=n; i>=1; i--){
        suf[i][0] = suf[i+1][0];
        suf[i][1] = suf[i+1][1];
        suf[i][2] = suf[i+1][2];
        if(s[i-1] == 'I'){
            suf[i][0]++;
        }
        else if(s[i-1] == 'O'){
            suf[i][1] += suf[i][0];
        }
        else{
            suf[i][2] += suf[i][1];
        }
    }
    ll res = 0;
    for(int i=0; i<=n; i++){
        res = max(res, suf[i+1][1]);
        res = max(res, pre[i][1]);
        res = max(res, pre[i][0]*suf[i+1][0]);
    }
    cout << res + pre[n][2] << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 1 ms 460 KB Output is correct
29 Correct 1 ms 460 KB Output is correct
30 Correct 1 ms 460 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 0 ms 332 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 0 ms 332 KB Output is correct
16 Correct 1 ms 460 KB Output is correct
17 Correct 1 ms 460 KB Output is correct
18 Correct 1 ms 460 KB Output is correct
19 Correct 1 ms 460 KB Output is correct
20 Correct 1 ms 460 KB Output is correct
21 Correct 1 ms 460 KB Output is correct
22 Correct 1 ms 460 KB Output is correct
23 Correct 1 ms 460 KB Output is correct
24 Correct 1 ms 460 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 460 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 1 ms 460 KB Output is correct
29 Correct 1 ms 460 KB Output is correct
30 Correct 1 ms 460 KB Output is correct
31 Correct 4 ms 5196 KB Output is correct
32 Correct 4 ms 5324 KB Output is correct
33 Correct 4 ms 5232 KB Output is correct
34 Correct 4 ms 5232 KB Output is correct
35 Correct 4 ms 5320 KB Output is correct
36 Correct 5 ms 5232 KB Output is correct
37 Correct 5 ms 5196 KB Output is correct
38 Correct 5 ms 5292 KB Output is correct
39 Correct 5 ms 5196 KB Output is correct
40 Correct 5 ms 5232 KB Output is correct
41 Correct 5 ms 5288 KB Output is correct
42 Correct 4 ms 5232 KB Output is correct
43 Correct 5 ms 5232 KB Output is correct
44 Correct 4 ms 5196 KB Output is correct
45 Correct 4 ms 5196 KB Output is correct