Submission #106927

# Submission time Handle Problem Language Result Execution time Memory
106927 2019-04-21T06:23:23 Z tjd229 Gap (APIO16_gap) C++14
100 / 100
80 ms 3256 KB
#include "gap.h"
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
long long findGap(int T, int N)
{
	if (!N) return 0;
	vector<ll> a;
	ll res = 0;
	if (--T) {
		ll mn, mx,bnd;
		MinMax(0,1e18,&mn,&bnd);
		ll d = (bnd - mn)/(N-1);
		a.push_back(mn); a.push_back(bnd);
		ll l = mn, r = mn + d;
		res = d;
		for (;l< bnd;l+=d+1,r+=d+1) {
			MinMax(l, r, &mn, &mx);
			if (mn != -1) a.push_back(mn);
			if (mx != -1) a.push_back(mx);
		}
	}
	else {
		ll mn = -1, mx = (ll)1e18+1;
		for (int i = N; i > 0; i -= 2) {
			MinMax(mn + 1, mx - 1,&mn,&mx);
			a.push_back(mn); a.push_back(mx);
		}
	}
	sort(a.begin(), a.end());
	for (int i = 1; i < a.size(); ++i) {
		ll d = a[i] - a[i - 1];
		if (res < d) res = d;
	}
	return res;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:32:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 1; i < a.size(); ++i) {
                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 3 ms 284 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 2 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 KB Output is correct
10 Correct 2 ms 256 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 18 ms 896 KB Output is correct
17 Correct 22 ms 908 KB Output is correct
18 Correct 15 ms 896 KB Output is correct
19 Correct 15 ms 896 KB Output is correct
20 Correct 13 ms 896 KB Output is correct
21 Correct 70 ms 2256 KB Output is correct
22 Correct 61 ms 2288 KB Output is correct
23 Correct 69 ms 2288 KB Output is correct
24 Correct 65 ms 2288 KB Output is correct
25 Correct 72 ms 2304 KB Output is correct
26 Correct 75 ms 2288 KB Output is correct
27 Correct 59 ms 2288 KB Output is correct
28 Correct 61 ms 2200 KB Output is correct
29 Correct 55 ms 2416 KB Output is correct
30 Correct 42 ms 2288 KB Output is correct
31 Correct 2 ms 256 KB Output is correct
32 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 256 KB Output is correct
8 Correct 2 ms 256 KB Output is correct
9 Correct 2 ms 256 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 4 ms 384 KB Output is correct
16 Correct 18 ms 896 KB Output is correct
17 Correct 18 ms 896 KB Output is correct
18 Correct 20 ms 896 KB Output is correct
19 Correct 21 ms 932 KB Output is correct
20 Correct 13 ms 512 KB Output is correct
21 Correct 77 ms 2284 KB Output is correct
22 Correct 76 ms 2288 KB Output is correct
23 Correct 77 ms 2288 KB Output is correct
24 Correct 80 ms 2384 KB Output is correct
25 Correct 74 ms 3256 KB Output is correct
26 Correct 69 ms 2240 KB Output is correct
27 Correct 68 ms 2288 KB Output is correct
28 Correct 79 ms 2400 KB Output is correct
29 Correct 70 ms 2288 KB Output is correct
30 Correct 39 ms 1656 KB Output is correct
31 Correct 2 ms 256 KB Output is correct
32 Correct 2 ms 356 KB Output is correct