Submission #262025

# Submission time Handle Problem Language Result Execution time Memory
262025 2020-08-12T09:39:02 Z amoo_safar Gap (APIO16_gap) C++17
100 / 100
78 ms 3308 KB
#include <bits/stdc++.h>
#include "gap.h"

#define pb push_back

using namespace std;

typedef long long ll;

const ll Inf = 1e18;

ll findGap(int Tc, int N){
	if(Tc == 1){
		vector<ll> V;

		ll L, R, L2, R2;
		MinMax(0ll, Inf, &L, &R);
		V.pb(L);
		V.pb(R);
		while( ((int) V.size()) < N){
			L ++;
			R --;
			MinMax(L, R, &L2, &R2);
			L = L2;
			R = R2;
			V.pb(L); V.pb(R);
		}
		sort(V.begin(), V.end());
		
		ll ans = 0;
		for(int i = 0; i + 1 < (int) V.size(); i++) ans = max(ans, V[i + 1] - V[i]);
		return ans;	
	}
	ll L, R, S, T;
	MinMax(0ll, Inf, &L, &R);
	ll D = (R - L) / (N - 1);
	ll md = (R - L) % (N - 1);
	ll pos = L;
	ll st;
	vector<ll> V;
	V.pb(L);
	V.pb(R);
	for(int i = 0; i < N - 1; i++){
		st = D;
		if(i < md) st ++;
		MinMax(pos, pos + st - 1, &S, &T);
		if(S != -1){
			V.push_back(S);
			V.push_back(T);
		}
		pos += st;
	}
	sort(V.begin(), V.end());
	ll ans = D + min(md, 1ll);
	for(int i = 0; i + 1 < (int) V.size(); i++) ans = max(ans, V[i + 1] - V[i]);
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 14 ms 896 KB Output is correct
17 Correct 14 ms 896 KB Output is correct
18 Correct 14 ms 896 KB Output is correct
19 Correct 16 ms 896 KB Output is correct
20 Correct 12 ms 896 KB Output is correct
21 Correct 55 ms 2292 KB Output is correct
22 Correct 55 ms 2288 KB Output is correct
23 Correct 56 ms 2212 KB Output is correct
24 Correct 56 ms 2288 KB Output is correct
25 Correct 48 ms 2336 KB Output is correct
26 Correct 57 ms 2288 KB Output is correct
27 Correct 59 ms 2308 KB Output is correct
28 Correct 78 ms 2336 KB Output is correct
29 Correct 58 ms 2304 KB Output is correct
30 Correct 41 ms 2216 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 17 ms 896 KB Output is correct
17 Correct 17 ms 1088 KB Output is correct
18 Correct 17 ms 896 KB Output is correct
19 Correct 17 ms 896 KB Output is correct
20 Correct 7 ms 512 KB Output is correct
21 Correct 71 ms 2288 KB Output is correct
22 Correct 73 ms 2288 KB Output is correct
23 Correct 74 ms 2288 KB Output is correct
24 Correct 75 ms 2288 KB Output is correct
25 Correct 70 ms 3308 KB Output is correct
26 Correct 70 ms 2288 KB Output is correct
27 Correct 70 ms 2280 KB Output is correct
28 Correct 74 ms 2288 KB Output is correct
29 Correct 77 ms 2288 KB Output is correct
30 Correct 34 ms 1532 KB Output is correct
31 Correct 0 ms 384 KB Output is correct
32 Correct 0 ms 384 KB Output is correct