Submission #105977

# Submission time Handle Problem Language Result Execution time Memory
105977 2019-04-16T03:30:14 Z Hideo Gap (APIO16_gap) C++14
100 / 100
88 ms 2812 KB
#include <bits/stdc++.h>
//#include "grader.cpp"
#include "gap.h"

using namespace std;

#define ll long long
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define vi vector < int >
#define vl vector < ll >
#define pl pair < ll, ll >
#define pii pair < int, pl >
#define vii vector < pl >

const int MAXN = 1e5 + 7;
const ll INF = 1e18;

ll mn, mx, l, ans;
ll s, f, sz, r;

pl a[MAXN];

long long findGap(int T, int N){
	if (T == 1){
        l = 1, r = N, f = INF;
        while (r >= l){
            MinMax(s, f, &mn, &mx);
            f = mx - 1;
            s = mn + 1;
            a[l].fr = mn; a[r].fr = mx;
            l++; r--;
        }
        for (int i = 2; i <= N; i++)
            ans = max(ans, a[i].fr - a[i - 1].fr);
	}
	else {
        MinMax(0, INF, &s, &f);
        sz = (f - s - 1) / (N - 1);
        r = (f - s - 1) % (N - 1);
        a[1] = {s, s};
        a[N + 1] = {f, f};
        l = s + 1;
        for (int i = 2; i <= N; i++){
            if (r){
                r--;
                MinMax(l, l + sz, &mn, &mx);
                if (mn != -1)
                    a[i] = {mn, mx};
                else
                    a[i] = a[i - 1];
                l = l + sz + 1;
            }
            else {
                MinMax(l, l + sz - 1, &mn, &mx);
                if (mn != -1)
                    a[i] = {mn, mx};
                else
                    a[i] = a[i - 1];
                l = l + sz;
            }
            ans = max(ans, a[i].fr - a[i - 1].sc);
        }
        ans = max(ans, a[N + 1].fr - a[N].sc);

	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 256 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 14 ms 896 KB Output is correct
17 Correct 14 ms 1024 KB Output is correct
18 Correct 13 ms 896 KB Output is correct
19 Correct 16 ms 1024 KB Output is correct
20 Correct 12 ms 1024 KB Output is correct
21 Correct 57 ms 2680 KB Output is correct
22 Correct 53 ms 2680 KB Output is correct
23 Correct 63 ms 2808 KB Output is correct
24 Correct 49 ms 2680 KB Output is correct
25 Correct 48 ms 2680 KB Output is correct
26 Correct 54 ms 2652 KB Output is correct
27 Correct 51 ms 2812 KB Output is correct
28 Correct 48 ms 2680 KB Output is correct
29 Correct 54 ms 2680 KB Output is correct
30 Correct 36 ms 2680 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 3 ms 384 KB Output is correct
6 Correct 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 3 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 17 ms 896 KB Output is correct
17 Correct 17 ms 1024 KB Output is correct
18 Correct 21 ms 1024 KB Output is correct
19 Correct 16 ms 896 KB Output is correct
20 Correct 9 ms 896 KB Output is correct
21 Correct 83 ms 2680 KB Output is correct
22 Correct 71 ms 2680 KB Output is correct
23 Correct 70 ms 2680 KB Output is correct
24 Correct 71 ms 2680 KB Output is correct
25 Correct 64 ms 2808 KB Output is correct
26 Correct 69 ms 2680 KB Output is correct
27 Correct 65 ms 2680 KB Output is correct
28 Correct 70 ms 2636 KB Output is correct
29 Correct 88 ms 2684 KB Output is correct
30 Correct 46 ms 2680 KB Output is correct
31 Correct 3 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct