Submission #1107483

# Submission time Handle Problem Language Result Execution time Memory
1107483 2024-11-01T09:31:30 Z evenvalue Gap (APIO16_gap) C++17
70 / 100
48 ms 5884 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;

template<typename T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using max_heap = priority_queue<T, vector<T>, less<T>>;

#define int long long

constexpr int kInf = 1e18;
constexpr int kMod = 1e9 + 7;

pair<int, int> ask(const int l, const int r) {
  int mn, mx;
  MinMax(l, r, &mn, &mx);
  return {mn, mx};
}

int findGap(int32_t T, int32_t n) {
  auto [l, r] = ask(0, kInf);
  if (r - l + 1 == n) return 1;

  const int each = (r - l - 1) / (n - 1);
  const int extra = (r - l - 1) % (n - 1);

  int last = l;
  vector<int> elems = {l};
  for (int i = 1; i <= n - 1; i++) {
    const int len = each + (i <= extra);
    const int a = last + 1;
    const int b = a + len - 1;
    const auto [x, y] = ask(a, b);
    if (x != -1) elems.push_back(x);
    if (y != -1) elems.push_back(y);
    last = b;
  }

  elems.push_back(r);

  int ans = 0;
  for (int i = 1; i < elems.size(); i++) {
    ans = max(ans, elems[i] - elems[i - 1]);
  }

  return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int32_t, int32_t)':
gap.cpp:43:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |   for (int i = 1; i < elems.size(); i++) {
      |                   ~~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Output isn't correct
2 Incorrect 1 ms 2384 KB Output isn't correct
3 Incorrect 1 ms 2384 KB Output isn't correct
4 Incorrect 1 ms 2384 KB Output isn't correct
5 Incorrect 2 ms 2384 KB Output isn't correct
6 Incorrect 1 ms 2384 KB Output isn't correct
7 Incorrect 1 ms 2384 KB Output isn't correct
8 Incorrect 1 ms 2384 KB Output isn't correct
9 Incorrect 1 ms 2384 KB Output isn't correct
10 Incorrect 1 ms 2384 KB Output isn't correct
11 Incorrect 1 ms 2552 KB Output isn't correct
12 Incorrect 2 ms 2384 KB Output isn't correct
13 Incorrect 2 ms 2384 KB Output isn't correct
14 Incorrect 1 ms 2384 KB Output isn't correct
15 Incorrect 2 ms 2384 KB Output isn't correct
16 Incorrect 10 ms 2896 KB Output isn't correct
17 Incorrect 10 ms 2896 KB Output isn't correct
18 Incorrect 9 ms 2872 KB Output isn't correct
19 Incorrect 10 ms 2896 KB Output isn't correct
20 Incorrect 5 ms 2384 KB Output isn't correct
21 Incorrect 37 ms 3932 KB Output isn't correct
22 Incorrect 39 ms 3784 KB Output isn't correct
23 Incorrect 46 ms 3768 KB Output isn't correct
24 Incorrect 43 ms 3880 KB Output isn't correct
25 Incorrect 43 ms 5884 KB Output isn't correct
26 Incorrect 39 ms 3784 KB Output isn't correct
27 Incorrect 46 ms 3784 KB Output isn't correct
28 Incorrect 43 ms 3776 KB Output isn't correct
29 Incorrect 41 ms 3968 KB Output isn't correct
30 Incorrect 29 ms 3144 KB Output isn't correct
31 Incorrect 1 ms 2384 KB Output isn't correct
32 Incorrect 1 ms 2384 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2384 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 1 ms 2384 KB Output is correct
4 Correct 1 ms 2384 KB Output is correct
5 Correct 1 ms 2384 KB Output is correct
6 Correct 1 ms 2384 KB Output is correct
7 Correct 1 ms 2384 KB Output is correct
8 Correct 1 ms 2384 KB Output is correct
9 Correct 1 ms 2384 KB Output is correct
10 Correct 1 ms 2384 KB Output is correct
11 Correct 1 ms 2384 KB Output is correct
12 Correct 1 ms 2556 KB Output is correct
13 Correct 1 ms 2384 KB Output is correct
14 Correct 1 ms 2384 KB Output is correct
15 Correct 1 ms 2384 KB Output is correct
16 Correct 10 ms 2896 KB Output is correct
17 Correct 14 ms 2896 KB Output is correct
18 Correct 11 ms 2896 KB Output is correct
19 Correct 11 ms 2896 KB Output is correct
20 Correct 5 ms 2384 KB Output is correct
21 Correct 37 ms 3816 KB Output is correct
22 Correct 43 ms 3784 KB Output is correct
23 Correct 46 ms 3980 KB Output is correct
24 Correct 45 ms 3776 KB Output is correct
25 Correct 37 ms 5820 KB Output is correct
26 Correct 47 ms 3820 KB Output is correct
27 Correct 40 ms 3784 KB Output is correct
28 Correct 48 ms 3776 KB Output is correct
29 Correct 39 ms 3784 KB Output is correct
30 Correct 23 ms 3152 KB Output is correct
31 Correct 1 ms 2384 KB Output is correct
32 Correct 1 ms 2384 KB Output is correct