답안 #495335

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
495335 2021-12-18T13:17:44 Z 600Mihnea Monochrome Points (JOI20_monochrome) C++17
35 / 100
2000 ms 4504 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int N = 400000 + 7;
int n;
string s;


int main() {
  ios::sync_with_stdio(0); cin.tie(0);

  cin >> n >> s;

  vector<int> a, b;
  for (int i = 0; i < 2 * n; i++) {
    if (s[i] != s[0]) {
      a.push_back(i);
    }
    else {
      b.push_back(i);
    }
  }
  vector<ll> cnt(n);

  for (int shift = 0; shift < n; shift++) {
    for (int i = 0; i < n; i++) {

      int i2 = (i + shift) % n, l = min(a[i], b[i2]), r = max(a[i], b[i2]);
      int inside = r - l - 1;
      int outside = 2 * n - inside - 2;
      cnt[shift] += min(inside, outside);
    }
  }
  ll sol = 0;


  for (auto& x : cnt) {
    sol = max(sol, x);
  }
  cout << sol / 2 << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 0 ms 312 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 0 ms 312 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 312 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 0 ms 312 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 312 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 22 ms 324 KB Output is correct
35 Correct 20 ms 312 KB Output is correct
36 Correct 19 ms 336 KB Output is correct
37 Correct 18 ms 320 KB Output is correct
38 Correct 16 ms 368 KB Output is correct
39 Correct 18 ms 336 KB Output is correct
40 Correct 18 ms 444 KB Output is correct
41 Correct 14 ms 368 KB Output is correct
42 Correct 20 ms 336 KB Output is correct
43 Correct 19 ms 336 KB Output is correct
44 Correct 16 ms 336 KB Output is correct
45 Correct 18 ms 364 KB Output is correct
46 Correct 21 ms 336 KB Output is correct
47 Correct 19 ms 336 KB Output is correct
48 Correct 21 ms 312 KB Output is correct
49 Correct 18 ms 336 KB Output is correct
50 Correct 20 ms 336 KB Output is correct
51 Correct 20 ms 360 KB Output is correct
52 Correct 20 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 0 ms 312 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 1 ms 204 KB Output is correct
20 Correct 1 ms 204 KB Output is correct
21 Correct 1 ms 204 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 312 KB Output is correct
31 Correct 1 ms 204 KB Output is correct
32 Correct 1 ms 204 KB Output is correct
33 Correct 1 ms 204 KB Output is correct
34 Correct 22 ms 324 KB Output is correct
35 Correct 20 ms 312 KB Output is correct
36 Correct 19 ms 336 KB Output is correct
37 Correct 18 ms 320 KB Output is correct
38 Correct 16 ms 368 KB Output is correct
39 Correct 18 ms 336 KB Output is correct
40 Correct 18 ms 444 KB Output is correct
41 Correct 14 ms 368 KB Output is correct
42 Correct 20 ms 336 KB Output is correct
43 Correct 19 ms 336 KB Output is correct
44 Correct 16 ms 336 KB Output is correct
45 Correct 18 ms 364 KB Output is correct
46 Correct 21 ms 336 KB Output is correct
47 Correct 19 ms 336 KB Output is correct
48 Correct 21 ms 312 KB Output is correct
49 Correct 18 ms 336 KB Output is correct
50 Correct 20 ms 336 KB Output is correct
51 Correct 20 ms 360 KB Output is correct
52 Correct 20 ms 364 KB Output is correct
53 Execution timed out 2029 ms 4504 KB Time limit exceeded
54 Halted 0 ms 0 KB -