Submission #539182

# Submission time Handle Problem Language Result Execution time Memory
539182 2022-03-18T14:28:46 Z timreizin Gap (APIO16_gap) C++17
100 / 100
72 ms 3208 KB
#include "gap.h"
#include <vector>
#include <algorithm>

using namespace std;

using ll = long long;

long long findGap(int t, int n)
{
    vector<ll> arr;
    if (t == 1)
    {
        ll a = -1, b = (ll)1e18 + 1;
        for (int i = 0; i < (n + 1) / 2; ++i)
        {
            MinMax(a + 1, b - 1, &a, &b);
            arr.push_back(a);
            arr.push_back(b);
        }
        sort(arr.begin(), arr.end());
    }
    else
    {
        ll a, b;
        MinMax(0, 1e18, &a, &b);
        arr.push_back(a);
        ll x = (b - a + n - 2) / (n - 1);
        for (ll i = a + 1; i < b; i += x)
        {
            ll l, r;
            MinMax(i, i + x - 1, &l, &r);
            if (l != -1)
            {
                arr.push_back(l);
                arr.push_back(r);
            }
        }
        arr.push_back(b);
    }
    ll res = 0;
    for (int i = 0; i + 1 < arr.size(); ++i) res = max(res, arr[i + 1] - arr[i]);
    return res;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:42:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for (int i = 0; i + 1 < arr.size(); ++i) res = max(res, arr[i + 1] - arr[i]);
      |                     ~~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 304 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 15 ms 824 KB Output is correct
17 Correct 13 ms 848 KB Output is correct
18 Correct 12 ms 844 KB Output is correct
19 Correct 10 ms 880 KB Output is correct
20 Correct 9 ms 848 KB Output is correct
21 Correct 47 ms 2244 KB Output is correct
22 Correct 44 ms 2280 KB Output is correct
23 Correct 47 ms 2188 KB Output is correct
24 Correct 46 ms 2236 KB Output is correct
25 Correct 37 ms 2192 KB Output is correct
26 Correct 45 ms 2196 KB Output is correct
27 Correct 46 ms 2224 KB Output is correct
28 Correct 50 ms 2156 KB Output is correct
29 Correct 42 ms 2192 KB Output is correct
30 Correct 34 ms 2240 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 15 ms 856 KB Output is correct
17 Correct 18 ms 848 KB Output is correct
18 Correct 14 ms 848 KB Output is correct
19 Correct 14 ms 792 KB Output is correct
20 Correct 9 ms 448 KB Output is correct
21 Correct 53 ms 2228 KB Output is correct
22 Correct 54 ms 2240 KB Output is correct
23 Correct 60 ms 2196 KB Output is correct
24 Correct 66 ms 2168 KB Output is correct
25 Correct 47 ms 3208 KB Output is correct
26 Correct 58 ms 2224 KB Output is correct
27 Correct 72 ms 2508 KB Output is correct
28 Correct 53 ms 2240 KB Output is correct
29 Correct 52 ms 2212 KB Output is correct
30 Correct 31 ms 1388 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct