답안 #495338

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
495338 2021-12-18T13:22:31 Z 600Mihnea Monochrome Points (JOI20_monochrome) C++17
35 / 100
2000 ms 4564 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);

  ///freopen ("input", "r", stdin);

  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 i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a[i] < b[j]) {
        cnt[(n - i + j) % n] += min(b[j] - a[i] - 1, 2 * (n - 1) - (b[j] - a[i] - 1));
      }
    }
    for (int j = 0; j < n; j++) {
      if (a[i] > b[j]) {
        cnt[(n - i + j) % n] += min(a[i] - b[j] - 1, 2 * (n - 1) - (a[i] - b[j] - 1));
      }
    }
  }
  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 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 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 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 316 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 320 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 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 316 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 320 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 332 KB Output is correct
35 Correct 22 ms 360 KB Output is correct
36 Correct 23 ms 360 KB Output is correct
37 Correct 20 ms 344 KB Output is correct
38 Correct 19 ms 332 KB Output is correct
39 Correct 22 ms 360 KB Output is correct
40 Correct 18 ms 332 KB Output is correct
41 Correct 18 ms 332 KB Output is correct
42 Correct 22 ms 356 KB Output is correct
43 Correct 23 ms 308 KB Output is correct
44 Correct 19 ms 332 KB Output is correct
45 Correct 20 ms 360 KB Output is correct
46 Correct 23 ms 332 KB Output is correct
47 Correct 21 ms 360 KB Output is correct
48 Correct 23 ms 320 KB Output is correct
49 Correct 20 ms 332 KB Output is correct
50 Correct 23 ms 360 KB Output is correct
51 Correct 23 ms 332 KB Output is correct
52 Correct 25 ms 348 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 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 316 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 316 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 320 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 332 KB Output is correct
35 Correct 22 ms 360 KB Output is correct
36 Correct 23 ms 360 KB Output is correct
37 Correct 20 ms 344 KB Output is correct
38 Correct 19 ms 332 KB Output is correct
39 Correct 22 ms 360 KB Output is correct
40 Correct 18 ms 332 KB Output is correct
41 Correct 18 ms 332 KB Output is correct
42 Correct 22 ms 356 KB Output is correct
43 Correct 23 ms 308 KB Output is correct
44 Correct 19 ms 332 KB Output is correct
45 Correct 20 ms 360 KB Output is correct
46 Correct 23 ms 332 KB Output is correct
47 Correct 21 ms 360 KB Output is correct
48 Correct 23 ms 320 KB Output is correct
49 Correct 20 ms 332 KB Output is correct
50 Correct 23 ms 360 KB Output is correct
51 Correct 23 ms 332 KB Output is correct
52 Correct 25 ms 348 KB Output is correct
53 Execution timed out 2054 ms 4564 KB Time limit exceeded
54 Halted 0 ms 0 KB -