Submission #92005

# Submission time Handle Problem Language Result Execution time Memory
92005 2019-01-01T00:08:22 Z updown1 Gap (APIO16_gap) C++17
89.1236 / 100
96 ms 5776 KB
/*
https://codeforces.com/blog/entry/44657?#comment-293060
*/
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i, a, b) for(int i=a; i<b; i++)
#define ffi For(i, 2, N)
#define ffj For(j, 0, N)
#define ffa ffi ffj
#define ss <<" "<<
#define c <<" : "<<
#define w cout
#define e endl//"\n"
#define pb push_back
#define mp make_pair
#define a first
#define b second
//#define int ll
const int MAXN=100000;
///500,000,000
long long findGap(int T, int N) {
    if (T == 1) {
        ll ans[N], l = 0, r = N-1, mn, mx;
        while (r >= l) {
            if (l == 0) MinMax(0, 1e18, &mn, &mx);
            else if (ans[l-1]+1 <= ans[r+1]-1) MinMax(ans[l-1]+1, ans[r+1]-1, &mn, &mx);
            ans[l] = mn; ans[r] = mx;
            l++; r--;
        }
        ll ret = 0;
        For (i, 1, N) ret = max(ret, ans[i] - ans[i-1]);
        return ret;
    }
    ll l, r, mn, mx;
    MinMax(0, 1e18, &l, &r);
    set<ll> vals; vals.insert(l); vals.insert(r);
    ll ad = (r-l+N-2)/(N-1);
    For (i, 0, N-1) if (min(r-1, l+(i+1)*ad+1) >= l+i*ad+1) {
        MinMax(l+i*ad+1, min(r-1, l+(i+1)*ad+1), &mn, &mx); vals.insert(mn); vals.insert(mx);
    }
    ll prev = l;
    ll ret = 0;
    for (ll i: vals) {
        if (i == -1) continue;
        ret = max(ret, i-prev);
        prev = i;
    }
	return ret;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 248 KB Output is correct
16 Correct 13 ms 760 KB Output is correct
17 Correct 12 ms 760 KB Output is correct
18 Correct 13 ms 760 KB Output is correct
19 Correct 13 ms 712 KB Output is correct
20 Correct 10 ms 760 KB Output is correct
21 Correct 47 ms 1912 KB Output is correct
22 Correct 46 ms 1912 KB Output is correct
23 Correct 46 ms 1912 KB Output is correct
24 Correct 46 ms 2040 KB Output is correct
25 Correct 39 ms 1912 KB Output is correct
26 Correct 45 ms 2124 KB Output is correct
27 Correct 45 ms 1912 KB Output is correct
28 Correct 45 ms 1912 KB Output is correct
29 Correct 45 ms 1912 KB Output is correct
30 Correct 33 ms 1912 KB Output is correct
31 Correct 2 ms 380 KB Output is correct
32 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 22 ms 1656 KB Output is correct
17 Correct 23 ms 1544 KB Output is correct
18 Correct 22 ms 1668 KB Output is correct
19 Correct 23 ms 1528 KB Output is correct
20 Partially correct 9 ms 632 KB Partially correct
21 Correct 94 ms 5368 KB Output is correct
22 Correct 96 ms 5240 KB Output is correct
23 Correct 93 ms 5240 KB Output is correct
24 Correct 94 ms 5244 KB Output is correct
25 Correct 96 ms 5776 KB Output is correct
26 Correct 93 ms 5412 KB Output is correct
27 Correct 94 ms 5260 KB Output is correct
28 Correct 94 ms 5288 KB Output is correct
29 Correct 92 ms 5240 KB Output is correct
30 Partially correct 37 ms 1528 KB Partially correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct