답안 #1114469

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1114469 2024-11-19T00:03:55 Z dynam1c Sprinklers (CEOI24_sprinklers) C++17
26 / 100
99 ms 3668 KB
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(n), f(m);
  for (int& e : s)
    cin >> e;
  for (int& e : f)
    cin >> e;

  vector<char> d(n);
  auto check = [&](int k) {
    d.assign(n, 0);
    vector<int> x(n+1);
    x[0] = -1;
    int j = 0;
    int li = -1, lj;
    for (int i = 0; i < n; i++) {
      if (s[i] <= x[i])
        x[i+1] = s[i]+k, d[i] = 'R';
      else if (j < m && f[j] < s[i]) {
        if (s[i]-f[j] > k)
          return false;
        x[i+1] = s[i], d[i] = 'L';
        if (li >= 0 && s[i]-k <= f[lj]) {
          x[i+1] = s[li]+k;
          d[li] = 'R';
        }
        li = i, lj = j;
      } else
        x[i+1] = s[i]+k, d[i] = 'R';
      while (j < m && f[j] <= x[i+1])
        j++;
    }
    return j == m;
  };

  if (!check(1e9)) {
    cout << -1 << endl;
    return 0;
  }

  int l = -1, r = 1e9;
  while (r-l > 1) {
    int m = (l+r)/2;
    if (check(m))
      r = m;
    else
      l = m;
  }

  check(r);
  cout << r << endl;
  for (char c : d)
    cout << c;
  cout << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Correct
2 Correct 1 ms 336 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Correct
2 Correct 21 ms 592 KB Correct
3 Correct 1 ms 336 KB Correct
4 Correct 23 ms 592 KB Correct
5 Correct 27 ms 592 KB Correct
6 Correct 1 ms 336 KB Correct
7 Correct 1 ms 336 KB Correct
8 Correct 5 ms 336 KB Correct
9 Correct 2 ms 336 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Correct
2 Correct 28 ms 592 KB Correct
3 Correct 6 ms 336 KB Correct
4 Correct 67 ms 1588 KB Correct
5 Correct 75 ms 1592 KB Correct
6 Correct 1 ms 336 KB Correct
7 Correct 1 ms 336 KB Correct
8 Correct 65 ms 1728 KB Correct
9 Correct 59 ms 1588 KB Correct
10 Correct 77 ms 1584 KB Correct
11 Correct 38 ms 1332 KB Correct
12 Correct 48 ms 2320 KB Correct
13 Correct 58 ms 2640 KB Correct
14 Correct 56 ms 2928 KB Correct
15 Correct 62 ms 3016 KB Correct
16 Correct 49 ms 2472 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Correct
2 Correct 1 ms 336 KB Correct
3 Correct 1 ms 336 KB Correct
4 Correct 1 ms 336 KB Correct
5 Correct 1 ms 336 KB Correct
6 Correct 1 ms 336 KB Correct
7 Correct 1 ms 336 KB Correct
8 Correct 1 ms 336 KB Correct
9 Correct 2 ms 336 KB Correct
10 Correct 2 ms 336 KB Correct
11 Correct 1 ms 336 KB Correct
12 Correct 1 ms 504 KB Correct
13 Correct 1 ms 336 KB Correct
14 Correct 1 ms 348 KB Correct
15 Correct 1 ms 336 KB Correct
16 Correct 1 ms 336 KB Correct
17 Correct 1 ms 336 KB Correct
18 Correct 1 ms 336 KB Correct
19 Correct 1 ms 336 KB Correct
20 Correct 1 ms 336 KB Correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Correct
2 Correct 31 ms 860 KB Correct
3 Correct 99 ms 1568 KB Correct
4 Correct 89 ms 1728 KB Correct
5 Correct 88 ms 1728 KB Correct
6 Correct 94 ms 1696 KB Correct
7 Correct 86 ms 3636 KB Correct
8 Correct 84 ms 3528 KB Correct
9 Correct 98 ms 3668 KB Correct
10 Correct 89 ms 3500 KB Correct
11 Correct 91 ms 3520 KB Correct
12 Correct 1 ms 336 KB Correct
13 Correct 1 ms 336 KB Correct
14 Correct 55 ms 2276 KB Correct
15 Correct 43 ms 2248 KB Correct
16 Correct 44 ms 2240 KB Correct
17 Correct 36 ms 2248 KB Correct
18 Correct 39 ms 2496 KB Correct
19 Correct 44 ms 2804 KB Correct
20 Correct 82 ms 3264 KB Correct
21 Incorrect 72 ms 3264 KB User solution is incorrect
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Correct
2 Correct 1 ms 336 KB Correct
3 Correct 21 ms 592 KB Correct
4 Correct 1 ms 336 KB Correct
5 Correct 23 ms 592 KB Correct
6 Correct 27 ms 592 KB Correct
7 Correct 1 ms 336 KB Correct
8 Correct 1 ms 336 KB Correct
9 Correct 5 ms 336 KB Correct
10 Correct 2 ms 336 KB Correct
11 Correct 28 ms 592 KB Correct
12 Correct 6 ms 336 KB Correct
13 Correct 67 ms 1588 KB Correct
14 Correct 75 ms 1592 KB Correct
15 Correct 1 ms 336 KB Correct
16 Correct 1 ms 336 KB Correct
17 Correct 65 ms 1728 KB Correct
18 Correct 59 ms 1588 KB Correct
19 Correct 77 ms 1584 KB Correct
20 Correct 38 ms 1332 KB Correct
21 Correct 48 ms 2320 KB Correct
22 Correct 58 ms 2640 KB Correct
23 Correct 56 ms 2928 KB Correct
24 Correct 62 ms 3016 KB Correct
25 Correct 49 ms 2472 KB Correct
26 Correct 1 ms 336 KB Correct
27 Correct 1 ms 336 KB Correct
28 Correct 1 ms 336 KB Correct
29 Correct 1 ms 336 KB Correct
30 Correct 1 ms 336 KB Correct
31 Correct 1 ms 336 KB Correct
32 Correct 2 ms 336 KB Correct
33 Correct 2 ms 336 KB Correct
34 Correct 1 ms 336 KB Correct
35 Correct 1 ms 504 KB Correct
36 Correct 1 ms 336 KB Correct
37 Correct 1 ms 348 KB Correct
38 Correct 1 ms 336 KB Correct
39 Correct 1 ms 336 KB Correct
40 Correct 1 ms 336 KB Correct
41 Correct 1 ms 336 KB Correct
42 Correct 1 ms 336 KB Correct
43 Correct 1 ms 336 KB Correct
44 Correct 31 ms 860 KB Correct
45 Correct 99 ms 1568 KB Correct
46 Correct 89 ms 1728 KB Correct
47 Correct 88 ms 1728 KB Correct
48 Correct 94 ms 1696 KB Correct
49 Correct 86 ms 3636 KB Correct
50 Correct 84 ms 3528 KB Correct
51 Correct 98 ms 3668 KB Correct
52 Correct 89 ms 3500 KB Correct
53 Correct 91 ms 3520 KB Correct
54 Correct 1 ms 336 KB Correct
55 Correct 1 ms 336 KB Correct
56 Correct 55 ms 2276 KB Correct
57 Correct 43 ms 2248 KB Correct
58 Correct 44 ms 2240 KB Correct
59 Correct 36 ms 2248 KB Correct
60 Correct 39 ms 2496 KB Correct
61 Correct 44 ms 2804 KB Correct
62 Correct 82 ms 3264 KB Correct
63 Incorrect 72 ms 3264 KB User solution is incorrect
64 Halted 0 ms 0 KB -