Submission #771390

#TimeUsernameProblemLanguageResultExecution timeMemory
771390gggkik스탬프 수집 (JOI16_ho_t2)C++14
0 / 100
1 ms340 KiB
#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]) }); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...