Submission #107818

# Submission time Handle Problem Language Result Execution time Memory
107818 2019-04-25T22:07:56 Z Noam527 Gap (APIO16_gap) C++17
89.0376 / 100
98 ms 3304 KB
#include <bits/stdc++.h>
#define CHECK cout << "ok" << endl
#define finish(x) return cout << x << endl, 0
typedef long long ll;
typedef long double ldb;
const int md = 1e9 + 7;
const ll inf = 1e18;
const int OO = 1;
const int OOO = 1;
using namespace std;

void MinMax(ll s, ll t, ll *mn, ll *mx);

ll findGap(int t, int n) {
	ll lo, hi, a, b;
	MinMax(0, inf, &lo, &hi);
	if (t == 2) {
		vector<ll> pos;
		ll d = (hi - lo) / (n - 1);
		pos.push_back(lo);
		for (ll i = lo + 1; i < hi; i += d) {
			MinMax(i, min(hi - 1, i + d - 1), &a, &b);
			if (a != -1) {
				pos.push_back(a);
				pos.push_back(b);
			}
		}
		pos.push_back(hi);
		ll rtn = pos[1] - pos[0];
		for (int i = 2; i < pos.size(); i++)
			rtn = max(rtn, pos[i] - pos[i - 1]);
		return rtn;
	}
	vector<ll> pos = { lo, hi };
	int left = n - 2;
	while (left > 0) {
		MinMax(lo + 1, hi - 1, &lo, &hi);
		pos.push_back(lo);
		pos.push_back(hi);
		left -= 2;
	}
	sort(pos.begin(), pos.end());
	ll rtn = pos[1] - pos[0];
	for (int i = 2; i < pos.size(); i++)
		rtn = max(rtn, pos[i] - pos[i - 1]);
	return rtn;
}
/*
int main() {
	ll ans = findGap(0, 4);
	cout << "my ans " << ans << '\n';
}
*/

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:30:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 2; i < pos.size(); i++)
                   ~~^~~~~~~~~~~~
gap.cpp:44:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 2; i < pos.size(); i++)
                  ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 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 3 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 3 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 15 ms 896 KB Output is correct
17 Correct 15 ms 896 KB Output is correct
18 Correct 19 ms 1024 KB Output is correct
19 Correct 16 ms 896 KB Output is correct
20 Correct 12 ms 1024 KB Output is correct
21 Correct 56 ms 2288 KB Output is correct
22 Correct 81 ms 2288 KB Output is correct
23 Correct 56 ms 2288 KB Output is correct
24 Correct 63 ms 2288 KB Output is correct
25 Correct 44 ms 2292 KB Output is correct
26 Correct 63 ms 2416 KB Output is correct
27 Correct 54 ms 2416 KB Output is correct
28 Correct 55 ms 2288 KB Output is correct
29 Correct 59 ms 2416 KB Output is correct
30 Correct 41 ms 2288 KB Output is correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 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 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 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 2 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 2 ms 384 KB Output is correct
15 Correct 3 ms 356 KB Output is correct
16 Correct 18 ms 896 KB Output is correct
17 Correct 18 ms 896 KB Output is correct
18 Correct 18 ms 1024 KB Output is correct
19 Correct 19 ms 896 KB Output is correct
20 Partially correct 13 ms 636 KB Partially correct
21 Correct 98 ms 2288 KB Output is correct
22 Correct 67 ms 2288 KB Output is correct
23 Correct 73 ms 2416 KB Output is correct
24 Correct 68 ms 2288 KB Output is correct
25 Correct 71 ms 3304 KB Output is correct
26 Correct 68 ms 2296 KB Output is correct
27 Correct 66 ms 2288 KB Output is correct
28 Correct 86 ms 2288 KB Output is correct
29 Correct 73 ms 2288 KB Output is correct
30 Partially correct 36 ms 1528 KB Partially correct
31 Correct 2 ms 384 KB Output is correct
32 Correct 2 ms 384 KB Output is correct