Submission #92004

# Submission time Handle Problem Language Result Execution time Memory
92004 2019-01-01T00:01:32 Z updown1 Gap (APIO16_gap) C++17
88.6743 / 100
97 ms 5752 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 (l+(i+1)*ad+1 >= l+i*ad+1) {
        MinMax(l+i*ad+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 256 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 380 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 376 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 760 KB Output is correct
20 Correct 9 ms 760 KB Output is correct
21 Correct 47 ms 1912 KB Output is correct
22 Correct 46 ms 1844 KB Output is correct
23 Correct 46 ms 1912 KB Output is correct
24 Correct 47 ms 1912 KB Output is correct
25 Correct 39 ms 1912 KB Output is correct
26 Correct 45 ms 1912 KB Output is correct
27 Correct 46 ms 1912 KB Output is correct
28 Correct 46 ms 1912 KB Output is correct
29 Correct 46 ms 1912 KB Output is correct
30 Correct 35 ms 2040 KB Output is correct
31 Correct 2 ms 376 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 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 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 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 1528 KB Output is correct
18 Correct 22 ms 1528 KB Output is correct
19 Correct 23 ms 1516 KB Output is correct
20 Partially correct 9 ms 504 KB Partially correct
21 Correct 93 ms 5240 KB Output is correct
22 Correct 96 ms 5288 KB Output is correct
23 Correct 95 ms 5368 KB Output is correct
24 Correct 93 ms 5368 KB Output is correct
25 Correct 97 ms 5752 KB Output is correct
26 Correct 95 ms 5364 KB Output is correct
27 Correct 92 ms 5452 KB Output is correct
28 Correct 94 ms 5460 KB Output is correct
29 Correct 95 ms 5296 KB Output is correct
30 Partially correct 36 ms 1528 KB Partially correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct