# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
117157 | onjo0127 | 스탬프 수집 (JOI16_ho_t2) | C++11 | 34 ms | 1380 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;
char S[100009];
int J[100009], I[100009];
int main() {
int N; scanf("%d",&N);
for(int i=1; i<=N; i++) scanf(" %c", &S[i]);
for(int i=1; i<=N; i++) J[i] = J[i-1] + (S[i] == 'J');
for(int i=N; i>=1; i--) I[i] = I[i+1] + (S[i] == 'I');
long long s1 = 0, s2 = 0, s3 = 0, mx = 0;
for(int i=1; i<=N; i++) {
if(S[i] == 'O') {
s1 += 1LL * (J[i] + 1) * I[i];
s2 += 1LL * J[i] * (I[i] + 1);
s3 += 1LL * J[i] * I[i];
}
mx = max(mx, 1LL * J[i] * I[i]);
}
printf("%lld", max({s1, s2, s3 + mx}));
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |