Submission #543744

# Submission time Handle Problem Language Result Execution time Memory
543744 2022-03-31T09:48:50 Z Vladth11 Gap (APIO16_gap) C++14
100 / 100
70 ms 1864 KB
#include <bits/stdc++.h>
#include "gap.h"
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
 
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <long double, pii> muchie;
 
const ll NMAX = 100001;
const ll VMAX = 1000001;
const ll INF = (1LL << 60);
const ll MOD = 90000000000000001;
const ll BLOCK = 1000000;
const ll base = 1000000001;
const ll nr_of_bits = 16;
 
ll a[100002];
 
long long findGap(int T, int N)
{
    a[0] = -1;
    a[N + 1] = 1e18;
  	a[N + 1] += 1;
    if(T == 1){
        int st = 1, dr = N;
        while(st <= dr){
            MinMax(a[st - 1] + 1, a[dr + 1] - 1, &a[st], &a[dr]);
            st++;
            dr--;
        }
        ll maxim = 0;
        for(int i = 2; i <= N; i++){
            maxim = max(maxim, a[i] - a[i - 1]);
        }
        return maxim;
    }
    ll first, last;
    MinMax(0, 1e18, &first, &last);
    ll BLOCK = last - first + N/2;
    BLOCK /= (N - 1);
    ll ultim = first, maxim = 0;
    for(ll i = first + 1; i + BLOCK - 1 < last; i += BLOCK){
        ll prim, doi;
        MinMax(i, i + BLOCK - 1, &prim, &doi);
        if(ultim != -1 && prim != -1)
            maxim = max(maxim, prim - ultim);
        if(doi != -1)
            ultim = doi;
    }
    maxim = max(maxim, last - ultim);
	return maxim;
}
# Verdict Execution time Memory Grader output
1 Correct 0 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 1 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 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 12 ms 688 KB Output is correct
17 Correct 9 ms 592 KB Output is correct
18 Correct 10 ms 592 KB Output is correct
19 Correct 11 ms 592 KB Output is correct
20 Correct 8 ms 640 KB Output is correct
21 Correct 46 ms 1740 KB Output is correct
22 Correct 45 ms 1864 KB Output is correct
23 Correct 46 ms 1832 KB Output is correct
24 Correct 40 ms 1780 KB Output is correct
25 Correct 50 ms 1848 KB Output is correct
26 Correct 49 ms 1832 KB Output is correct
27 Correct 40 ms 1832 KB Output is correct
28 Correct 41 ms 1828 KB Output is correct
29 Correct 44 ms 1836 KB Output is correct
30 Correct 34 ms 1844 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 0 ms 264 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 13 ms 428 KB Output is correct
17 Correct 13 ms 464 KB Output is correct
18 Correct 13 ms 432 KB Output is correct
19 Correct 13 ms 520 KB Output is correct
20 Correct 9 ms 464 KB Output is correct
21 Correct 69 ms 1092 KB Output is correct
22 Correct 57 ms 1060 KB Output is correct
23 Correct 67 ms 1084 KB Output is correct
24 Correct 63 ms 1020 KB Output is correct
25 Correct 58 ms 968 KB Output is correct
26 Correct 70 ms 1084 KB Output is correct
27 Correct 51 ms 1064 KB Output is correct
28 Correct 56 ms 1084 KB Output is correct
29 Correct 59 ms 1064 KB Output is correct
30 Correct 39 ms 1088 KB Output is correct
31 Correct 1 ms 208 KB Output is correct
32 Correct 1 ms 208 KB Output is correct