Submission #360305

# Submission time Handle Problem Language Result Execution time Memory
360305 2021-01-28T01:46:04 Z joylintp Gap (APIO16_gap) C++17
100 / 100
65 ms 3296 KB
#include "gap.h"
#include<bits/stdc++.h>
using namespace std;

long long findGap(int T, int N)
{
    long long l, r;
    MinMax(0, 1000000000000000000, &l, &r);

    if (N == 2)
        return r - l;

    if (T == 1)
    {
        vector<long long> a(N);
        a[0] = l, a[N - 1] = r;

        for (int i = 1; i <= N - i - 1; i++)
            MinMax(a[i - 1] + 1, a[N - i] - 1, &a[i], &a[N - i - 1]);

        long long mx = 0;
        for (int i = 0; i + 1 < N; i++)
            mx = max(mx, a[i + 1] - a[i]);
        return mx;
    }
    else
    {
        long long ma = (r - l - N - 1) / (N - 1) + !!((r - l - N - 1) % (N - 1)) + 1;

        long long x, y;
        vector<long long> a = {l};
        for (long long i = l + 1; i < r; i += ma + 1)
        {
            MinMax(i, min(r - 1, i + ma), &x, &y);
            if (x != -1)
                a.push_back(x), a.push_back(y);
        }
        a.push_back(r);

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

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:41:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         for (int i = 0; i + 1 < a.size(); i++)
      |                         ~~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 0 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 11 ms 748 KB Output is correct
17 Correct 11 ms 748 KB Output is correct
18 Correct 11 ms 748 KB Output is correct
19 Correct 11 ms 748 KB Output is correct
20 Correct 8 ms 748 KB Output is correct
21 Correct 42 ms 1900 KB Output is correct
22 Correct 42 ms 1900 KB Output is correct
23 Correct 42 ms 1900 KB Output is correct
24 Correct 43 ms 1900 KB Output is correct
25 Correct 37 ms 1900 KB Output is correct
26 Correct 42 ms 2020 KB Output is correct
27 Correct 46 ms 2080 KB Output is correct
28 Correct 43 ms 1900 KB Output is correct
29 Correct 42 ms 1900 KB Output is correct
30 Correct 34 ms 1900 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Correct 0 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 16 ms 876 KB Output is correct
17 Correct 16 ms 876 KB Output is correct
18 Correct 15 ms 876 KB Output is correct
19 Correct 15 ms 876 KB Output is correct
20 Correct 7 ms 492 KB Output is correct
21 Correct 60 ms 2452 KB Output is correct
22 Correct 62 ms 2388 KB Output is correct
23 Correct 60 ms 2276 KB Output is correct
24 Correct 65 ms 2276 KB Output is correct
25 Correct 60 ms 3296 KB Output is correct
26 Correct 62 ms 2276 KB Output is correct
27 Correct 61 ms 2276 KB Output is correct
28 Correct 61 ms 2276 KB Output is correct
29 Correct 61 ms 2276 KB Output is correct
30 Correct 30 ms 1516 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct