# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
771390 | gggkik | 스탬프 수집 (JOI16_ho_t2) | C++14 | 1 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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],
1LL*(O[0][i]+J[0][i])*I[1][i],
1LL*(I[0][i]+O[0][i])
});
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |