# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
771396 |
2023-07-02T23:37:59 Z |
gggkik |
None (JOI16_ho_t2) |
C++14 |
|
1 ms |
340 KB |
#include <bits/stdc++.h>
using namespace std;
const int MXN = 1e5+5;
int 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,
1LL*(J[0][i]+1)*O[1][i]+J[1][i],
1LL*(O[0][i]+J[0][i])*I[1][i]+J[1][i],
1LL*(I[0][i]+O[0][i])+J[1][i]
});
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |