Submission #982211

# Submission time Handle Problem Language Result Execution time Memory
982211 2024-05-14T03:03:29 Z NeroZein Growing Vegetables is Fun 5 (JOI24_vegetables5) C++17
30 / 100
5000 ms 17116 KB
#include "bits/stdc++.h"
using namespace std;

#ifdef Nero
#include "Deb.h"
#else
#define debug(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n * 2);
  vector<int> b(n), c(n);
  for (int i = 0; i < n * 2; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
  }
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  int ans = INT_MAX;
  for (int rep = 0; rep < 2; ++rep) {
    for (int f = 0; f <= n; ++f) {
      vector<int> v1, v2;
      for (int i = 0; i < n * 2; ++i) {
        if (i >= f && i < f + n) {
          v1.push_back(a[i]);
        } else {
          v2.push_back(a[i]); 
        }
      }
      int res = 0;
      sort(v1.begin(), v1.end());
      sort(v2.begin(), v2.end());
      for (int i = 0; i < n; ++i) {
        res = max(res, abs(v1[i] - b[i]));
        res = max(res, abs(v2[i] - c[i]));
      }
      ans = min(ans, res);
    }
    swap(b, c);
  }
  cout << ans << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 420 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 420 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 452 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 452 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 420 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 452 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 452 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 456 KB Output is correct
26 Correct 416 ms 572 KB Output is correct
27 Correct 397 ms 544 KB Output is correct
28 Correct 225 ms 516 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 425 ms 348 KB Output is correct
31 Correct 394 ms 540 KB Output is correct
32 Correct 79 ms 348 KB Output is correct
33 Correct 19 ms 348 KB Output is correct
34 Correct 436 ms 572 KB Output is correct
35 Correct 414 ms 540 KB Output is correct
36 Correct 413 ms 348 KB Output is correct
37 Correct 172 ms 348 KB Output is correct
38 Correct 185 ms 344 KB Output is correct
39 Correct 224 ms 576 KB Output is correct
40 Correct 438 ms 532 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5040 ms 17116 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 600 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 420 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 452 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 452 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 456 KB Output is correct
26 Correct 416 ms 572 KB Output is correct
27 Correct 397 ms 544 KB Output is correct
28 Correct 225 ms 516 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 425 ms 348 KB Output is correct
31 Correct 394 ms 540 KB Output is correct
32 Correct 79 ms 348 KB Output is correct
33 Correct 19 ms 348 KB Output is correct
34 Correct 436 ms 572 KB Output is correct
35 Correct 414 ms 540 KB Output is correct
36 Correct 413 ms 348 KB Output is correct
37 Correct 172 ms 348 KB Output is correct
38 Correct 185 ms 344 KB Output is correct
39 Correct 224 ms 576 KB Output is correct
40 Correct 438 ms 532 KB Output is correct
41 Execution timed out 5040 ms 17116 KB Time limit exceeded
42 Halted 0 ms 0 KB -