Submission #945364

# Submission time Handle Problem Language Result Execution time Memory
945364 2024-03-13T16:58:59 Z wii Gap (APIO16_gap) C++17
100 / 100
42 ms 4000 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

ll findGap(int T, int N) {
    ll res = 0;
    if (T == 1) {
        vector<ll> a;
        for (ll l = 0, r = 1e18; l <= r && a.size() < N; ) {
            ll mn, mx;
            MinMax(l, r, &mn, &mx);

            a.push_back(mn);
            a.push_back(mx);

            l = mn + 1;
            r = mx - 1;
        }

        sort(a.begin(), a.end());
        for (int i = 1; i < a.size(); ++i)
            res = max(res, a[i] - a[i - 1]);
    } else {
        ll l, r;
        MinMax(0, 1e18, &l, &r);

        ll step = (r - l + 1) / N;

        res = step;
        for (ll i = l + 1, pre = l; i <= r; i += step + 1) {
            ll mn, mx;
            MinMax(i, i + step, &mn, &mx);

            if (mn != -1) {
                res = max(res, mn - pre);
                pre = mx;
            }
        }
    }

	return res;
}

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:11:53: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   11 |         for (ll l = 0, r = 1e18; l <= r && a.size() < N; ) {
      |                                            ~~~~~~~~~^~~
gap.cpp:23:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         for (int i = 1; i < a.size(); ++i)
      |                         ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 2496 KB Output is correct
3 Correct 0 ms 2392 KB Output is correct
4 Correct 1 ms 2392 KB Output is correct
5 Correct 1 ms 2644 KB Output is correct
6 Correct 0 ms 2392 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 0 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 2 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2468 KB Output is correct
16 Correct 8 ms 2840 KB Output is correct
17 Correct 8 ms 3008 KB Output is correct
18 Correct 8 ms 2844 KB Output is correct
19 Correct 9 ms 2900 KB Output is correct
20 Correct 7 ms 2824 KB Output is correct
21 Correct 32 ms 3992 KB Output is correct
22 Correct 31 ms 3992 KB Output is correct
23 Correct 31 ms 3980 KB Output is correct
24 Correct 31 ms 3988 KB Output is correct
25 Correct 28 ms 3988 KB Output is correct
26 Correct 33 ms 3992 KB Output is correct
27 Correct 31 ms 3916 KB Output is correct
28 Correct 31 ms 4000 KB Output is correct
29 Correct 30 ms 3988 KB Output is correct
30 Correct 26 ms 3996 KB Output is correct
31 Correct 0 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2392 KB Output is correct
4 Correct 0 ms 2392 KB Output is correct
5 Correct 1 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 1 ms 2392 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 0 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 1 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 1 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 10 ms 2656 KB Output is correct
17 Correct 9 ms 2580 KB Output is correct
18 Correct 9 ms 2836 KB Output is correct
19 Correct 10 ms 2592 KB Output is correct
20 Correct 6 ms 2572 KB Output is correct
21 Correct 39 ms 2840 KB Output is correct
22 Correct 38 ms 2860 KB Output is correct
23 Correct 38 ms 2860 KB Output is correct
24 Correct 38 ms 3024 KB Output is correct
25 Correct 36 ms 2852 KB Output is correct
26 Correct 39 ms 2700 KB Output is correct
27 Correct 38 ms 2864 KB Output is correct
28 Correct 38 ms 3020 KB Output is correct
29 Correct 42 ms 2856 KB Output is correct
30 Correct 21 ms 2852 KB Output is correct
31 Correct 1 ms 2392 KB Output is correct
32 Correct 1 ms 2392 KB Output is correct