Submission #48386

# Submission time Handle Problem Language Result Execution time Memory
48386 2018-05-12T13:25:53 Z BThero Gap (APIO16_gap) C++17
0 / 100
77 ms 4192 KB
// Why am I so stupid? :c
#include <bits/stdc++.h>
#include "gap.h"

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

typedef long long ll;

using namespace std;

long long findGap(int t, int n) {
    ll arr[n + 5], que[2], ret = 0;
    int sz = 0;

    if (n <= 5) {
        arr[0] = 0, arr[n + 1] = (ll)1e18 + 1;
        int l = 1, r = n;

        while (l <= r) {
            MinMax(arr[l - 1] + 1, arr[r + 1] - 1, arr + l, arr + r);
            ++l, --r;
        }

        for (int i = 1; i < n; ++i) {
            ret = max(ret, arr[i + 1] - arr[i]);
        }
    }
    else {
        MinMax(1, (ll)1e18, que, que + 1);
        ll l = que[0], r = que[1];

        arr[++sz] = l++;
        arr[++sz] = r--;

        ll a = (r - l + 1) / (n - 1);
        ll b = (r - l + 1) % (n - 1);
        ll cur = l;

        for (int i = 1; i < n; ++i) {
            ll len = a;

            if (b > 0) {
                ++len, --b;
            }

            MinMax(cur, cur + len - 1, que, que + 1);

            if (que[0] != -1) {
                arr[++sz] = que[0];
                arr[++sz] = que[1];
            }

            cur += len;
        }

        sort(arr + 1, arr + sz + 1);

        for (int i = 1; i < sz; ++i) {
            ret = max(ret, arr[i + 1] - arr[i]);
        }
    }

    return ret;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Runtime error 2 ms 600 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 2 ms 748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Incorrect 2 ms 748 KB Output isn't correct
5 Runtime error 3 ms 748 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 2 ms 840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 2 ms 840 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 2 ms 920 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 2 ms 920 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Incorrect 2 ms 920 KB Output isn't correct
11 Runtime error 3 ms 1044 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 3 ms 1044 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 3 ms 1044 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 3 ms 1044 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 3 ms 1044 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 20 ms 1656 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 18 ms 1792 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 23 ms 1792 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 18 ms 1792 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Incorrect 10 ms 1792 KB Output isn't correct
21 Runtime error 66 ms 4036 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 77 ms 4036 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Runtime error 65 ms 4044 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 68 ms 4044 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 48 ms 4052 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 72 ms 4052 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Runtime error 71 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Runtime error 69 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 66 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Incorrect 39 ms 4176 KB Output isn't correct
31 Incorrect 2 ms 4176 KB Output isn't correct
32 Incorrect 2 ms 4176 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4176 KB Output is correct
2 Runtime error 3 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Correct 2 ms 4176 KB Output is correct
4 Correct 2 ms 4176 KB Output is correct
5 Runtime error 2 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 2 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 2 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 3 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 2 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Correct 2 ms 4176 KB Output is correct
11 Runtime error 3 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 3 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 3 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 3 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 3 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 17 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 18 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 18 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 18 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Correct 10 ms 4176 KB Output is correct
21 Runtime error 66 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
22 Runtime error 66 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
23 Runtime error 67 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
24 Runtime error 69 ms 4176 KB Execution killed with signal 11 (could be triggered by violating memory limits)
25 Runtime error 51 ms 4192 KB Execution killed with signal 11 (could be triggered by violating memory limits)
26 Runtime error 67 ms 4192 KB Execution killed with signal 11 (could be triggered by violating memory limits)
27 Runtime error 64 ms 4192 KB Execution killed with signal 11 (could be triggered by violating memory limits)
28 Runtime error 69 ms 4192 KB Execution killed with signal 11 (could be triggered by violating memory limits)
29 Runtime error 71 ms 4192 KB Execution killed with signal 11 (could be triggered by violating memory limits)
30 Correct 39 ms 4192 KB Output is correct
31 Correct 2 ms 4192 KB Output is correct
32 Correct 2 ms 4192 KB Output is correct