Submission #337946

# Submission time Handle Problem Language Result Execution time Memory
337946 2020-12-22T06:58:29 Z super_j6 Monochrome Points (JOI20_monochrome) C++14
35 / 100
95 ms 640 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string.h>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second

const int mxn = 8001;
int n;
int a[mxn];
int s[mxn][2];

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	
	for(int i = 1; i <= 2 * n; i++){
		char c;
		cin >> c;
		a[i] = a[i + 2 * n] = c == 'B' ? 0 : 1;
	}
	
	for(int i = 1; i <= 4 * n; i++){
		memcpy(s[i], s[i - 1], sizeof(s[i]));
		s[i][a[i]]++;
	}
	
	ll ret = 0;
	for(int t = 1; t <= 2 * n; t++){
		ll cur = 0;
		for(int i = 0, j = n, l = n; i < n; i++){
			if(a[t + i]){
				while(a[t + j]) j++;
				cur += s[t + 2 * n - 1][0] - s[t + j][0];
				cur += s[t + 2 * n - 1][1] - s[t + max(j, l - 1)][1];
				j++;
			}else{
				while(!a[t + l]) l++;
				cur += s[t + 2 * n - 1][1] - s[t + l][1];
				cur += s[t + 2 * n - 1][0] - s[t + max(j - 1, l)][0];
				l++;
			}
		}
		ret = max(ret, cur);
	}
	
	cout << ret << endl;

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 95 ms 492 KB Output is correct
35 Correct 95 ms 640 KB Output is correct
36 Correct 95 ms 620 KB Output is correct
37 Correct 86 ms 620 KB Output is correct
38 Correct 21 ms 492 KB Output is correct
39 Correct 25 ms 492 KB Output is correct
40 Correct 26 ms 492 KB Output is correct
41 Correct 36 ms 364 KB Output is correct
42 Correct 81 ms 492 KB Output is correct
43 Correct 27 ms 492 KB Output is correct
44 Correct 34 ms 492 KB Output is correct
45 Correct 33 ms 492 KB Output is correct
46 Correct 34 ms 492 KB Output is correct
47 Correct 35 ms 492 KB Output is correct
48 Correct 25 ms 492 KB Output is correct
49 Correct 22 ms 492 KB Output is correct
50 Correct 31 ms 492 KB Output is correct
51 Correct 23 ms 492 KB Output is correct
52 Correct 31 ms 492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 2 ms 364 KB Output is correct
17 Correct 2 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 1 ms 364 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 1 ms 364 KB Output is correct
28 Correct 1 ms 364 KB Output is correct
29 Correct 1 ms 364 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 95 ms 492 KB Output is correct
35 Correct 95 ms 640 KB Output is correct
36 Correct 95 ms 620 KB Output is correct
37 Correct 86 ms 620 KB Output is correct
38 Correct 21 ms 492 KB Output is correct
39 Correct 25 ms 492 KB Output is correct
40 Correct 26 ms 492 KB Output is correct
41 Correct 36 ms 364 KB Output is correct
42 Correct 81 ms 492 KB Output is correct
43 Correct 27 ms 492 KB Output is correct
44 Correct 34 ms 492 KB Output is correct
45 Correct 33 ms 492 KB Output is correct
46 Correct 34 ms 492 KB Output is correct
47 Correct 35 ms 492 KB Output is correct
48 Correct 25 ms 492 KB Output is correct
49 Correct 22 ms 492 KB Output is correct
50 Correct 31 ms 492 KB Output is correct
51 Correct 23 ms 492 KB Output is correct
52 Correct 31 ms 492 KB Output is correct
53 Runtime error 1 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
54 Halted 0 ms 0 KB -