# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
51658 | gs13105 | 스탬프 수집 (JOI16_ho_t2) | C++17 | 7 ms | 3840 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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <iterator>
using namespace std;
char arr[100010];
long long J[100010];
long long JO[100010];
long long I[100010];
long long OI[100010];
int main()
{
//freopen("in", "r", stdin);
//freopen("out", "w", stdout);
int n, i;
scanf("%d%s", &n, arr + 1);
for(i = 1; i <= n; i++)
J[i] = (arr[i] == 'J' ? 1 : 0) + J[i - 1];
for(i = 1; i <= n; i++)
JO[i] = (arr[i] == 'O' ? J[i - 1] : 0) + JO[i - 1];
for(i = n; i >= 1; i--)
I[i] = (arr[i] == 'I' ? 1 : 0) + I[i + 1];
for(i = n; i >= 1; i--)
OI[i] = (arr[i] == 'O' ? I[i + 1] : 0) + OI[i + 1];
long long JOI = 0;
for(i = 1; i <= n; i++)
if(arr[i] == 'I')
JOI += JO[i - 1];
long long res = 0;
for(i = 0; i <= n; i++)
{
res = max(OI[i + 1], res); // J
res = max(J[i] * I[i+1], res); // O
res = max(JO[i], res); // I
}
res += JOI;
printf("%lld\n", res);
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... |