# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
545451 | pokmui9909 | 스탬프 수집 (JOI16_ho_t2) | C++17 | 5 ms | 3768 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;
using ll = long long;
ll N; string S;
ll J[100005], JO[100005], I[100005], OI[100005];
int main(){
cin.tie(0) -> sync_with_stdio(false);
cin >> N >> S;
S = " " + S;
ll A = 0, B = 0;
for(int i = 1; i <= N; i++){
J[i] = J[i - 1], JO[i] = JO[i - 1];
if(S[i] == 'J') J[i]++;
if(S[i] == 'O') JO[i] += J[i];
if(S[i] == 'I') A += JO[i];
}
for(int i = N; i >= 1; i--){
I[i] = I[i + 1], OI[i] = OI[i + 1];
if(S[i] == 'I') I[i]++;
if(S[i] == 'O') OI[i] += I[i];
}
for(int i = 1; i <= N + 1; i++){
B = max({B, OI[i], J[i - 1] * I[i], JO[i - 1]});
}
cout << A + B;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |