Submission #145241

# Submission time Handle Problem Language Result Execution time Memory
145241 2019-08-19T11:19:21 Z dennisstar Gap (APIO16_gap) C++11
100 / 100
78 ms 2416 KB
#include "gap.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll ar[100010]; int tp;
ll mx, mn, gp;
priority_queue<ll, vector<ll>, greater<ll> > pq;
long long findGap(int T, int N)
{
	if (T==1) {
		mn=-1, mx=1000000000000000000ll+1ll;
		int cnt=0;
		for (int j=0; j<(N+1)/2; j++) {
			if (mn+1>mx-1) break;
			MinMax(mn+1, mx-1, &mn, &mx);
			pq.push(mn); pq.push(mx);
			cnt++;
		}
		gp=pq.top(); pq.pop();
		mx=0;
		while (!pq.empty()) {
			mn=gp; gp=pq.top(); pq.pop();
			mx=max(mx, gp-mn);
		}
		return mx;
	}
 	MinMax(0, 1000000000000000000ll, &mn, &mx);
	gp=(mx-mn+N-2)/(ll)(N-1);
	ll n, x;
	for (ll i=mn; i<mx; i+=gp) {
		MinMax(i, min(i+gp-1, mx-1), &n, &x);
		if (n==-1&&x==-1) continue;
		if (n==x) ar[tp++]=n;
		else {
			ar[tp++]=n; ar[tp++]=x;
		}
	}
	ar[tp++]=mx;
	ll ans=0;
	for (int j=0; j<tp-1; j++) ans=max(ans, ar[j+1]-ar[j]);
	return ans;
}
# 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 380 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 380 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 18 ms 1016 KB Output is correct
17 Correct 18 ms 892 KB Output is correct
18 Correct 18 ms 976 KB Output is correct
19 Correct 18 ms 1016 KB Output is correct
20 Correct 14 ms 892 KB Output is correct
21 Correct 65 ms 2284 KB Output is correct
22 Correct 65 ms 2288 KB Output is correct
23 Correct 66 ms 2292 KB Output is correct
24 Correct 66 ms 2284 KB Output is correct
25 Correct 60 ms 2288 KB Output is correct
26 Correct 65 ms 2288 KB Output is correct
27 Correct 66 ms 2292 KB Output is correct
28 Correct 65 ms 2288 KB Output is correct
29 Correct 66 ms 2288 KB Output is correct
30 Correct 52 ms 2416 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 3 ms 376 KB Output is correct
9 Correct 2 ms 380 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 260 KB Output is correct
16 Correct 20 ms 632 KB Output is correct
17 Correct 20 ms 740 KB Output is correct
18 Correct 20 ms 760 KB Output is correct
19 Correct 20 ms 632 KB Output is correct
20 Correct 10 ms 504 KB Output is correct
21 Correct 77 ms 1912 KB Output is correct
22 Correct 78 ms 1784 KB Output is correct
23 Correct 76 ms 1756 KB Output is correct
24 Correct 77 ms 1784 KB Output is correct
25 Correct 72 ms 1912 KB Output is correct
26 Correct 78 ms 1784 KB Output is correct
27 Correct 77 ms 1784 KB Output is correct
28 Correct 77 ms 1784 KB Output is correct
29 Correct 78 ms 1784 KB Output is correct
30 Correct 39 ms 1244 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct