# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
704725 |
2023-03-02T19:44:06 Z |
rainboy |
None (JOI16_ho_t2) |
C |
|
6 ms |
6740 KB |
#include <stdio.h>
#include <string.h>
#define N 100000
long long max(long long a, long long b) { return a > b ? a : b; }
int main() {
static char cc[N + 1];
static long long dp[N + 1][4], dq[N + 1][4];
int n, i, a;
long long ans;
scanf("%d%s", &n, cc);
dp[0][0] = 1;
for (i = 0; i < n; i++) {
memcpy(dp[i + 1], dp[i], sizeof dp[i]);
if (cc[i] == 'J')
dp[i + 1][1] += dp[i + 1][0];
else if (cc[i] == 'O')
dp[i + 1][2] += dp[i + 1][1];
else
dp[i + 1][3] += dp[i + 1][2];
}
dq[n][3] = 1;
for (i = n - 1; i >= 0; i--) {
memcpy(dq[i], dq[i + 1], sizeof dq[i + 1]);
if (cc[i] == 'J')
dq[i][0] += dq[i][1];
else if (cc[i] == 'O')
dq[i][1] += dq[i][2];
else
dq[i][2] += dq[i][3];
}
ans = 0;
for (i = 0; i <= n; i++)
for (a = 0; a < 3; a++)
ans = max(ans, dp[n][3] + dp[i][a] * dq[i][a + 1]);
printf("%lld\n", ans);
return 0;
}
Compilation message
2016_ho_t2.c: In function 'main':
2016_ho_t2.c:14:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
14 | scanf("%d%s", &n, cc);
| ^~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
288 KB |
Output is correct |
8 |
Correct |
0 ms |
292 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
296 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
288 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
288 KB |
Output is correct |
8 |
Correct |
0 ms |
292 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
296 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
288 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
512 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
420 KB |
Output is correct |
19 |
Correct |
0 ms |
416 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
0 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
23 |
Correct |
1 ms |
420 KB |
Output is correct |
24 |
Correct |
1 ms |
468 KB |
Output is correct |
25 |
Correct |
0 ms |
420 KB |
Output is correct |
26 |
Correct |
0 ms |
420 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
416 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
296 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
288 KB |
Output is correct |
8 |
Correct |
0 ms |
292 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
296 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
288 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
512 KB |
Output is correct |
17 |
Correct |
1 ms |
468 KB |
Output is correct |
18 |
Correct |
1 ms |
420 KB |
Output is correct |
19 |
Correct |
0 ms |
416 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
0 ms |
468 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
23 |
Correct |
1 ms |
420 KB |
Output is correct |
24 |
Correct |
1 ms |
468 KB |
Output is correct |
25 |
Correct |
0 ms |
420 KB |
Output is correct |
26 |
Correct |
0 ms |
420 KB |
Output is correct |
27 |
Correct |
1 ms |
468 KB |
Output is correct |
28 |
Correct |
1 ms |
416 KB |
Output is correct |
29 |
Correct |
1 ms |
468 KB |
Output is correct |
30 |
Correct |
1 ms |
468 KB |
Output is correct |
31 |
Correct |
5 ms |
6740 KB |
Output is correct |
32 |
Correct |
5 ms |
6676 KB |
Output is correct |
33 |
Correct |
5 ms |
6700 KB |
Output is correct |
34 |
Correct |
6 ms |
6704 KB |
Output is correct |
35 |
Correct |
6 ms |
6740 KB |
Output is correct |
36 |
Correct |
6 ms |
6740 KB |
Output is correct |
37 |
Correct |
5 ms |
6708 KB |
Output is correct |
38 |
Correct |
5 ms |
6740 KB |
Output is correct |
39 |
Correct |
5 ms |
6740 KB |
Output is correct |
40 |
Correct |
5 ms |
6704 KB |
Output is correct |
41 |
Correct |
5 ms |
6736 KB |
Output is correct |
42 |
Correct |
5 ms |
6684 KB |
Output is correct |
43 |
Correct |
5 ms |
6700 KB |
Output is correct |
44 |
Correct |
5 ms |
6740 KB |
Output is correct |
45 |
Correct |
5 ms |
6740 KB |
Output is correct |