Submission #1012040

# Submission time Handle Problem Language Result Execution time Memory
1012040 2024-07-01T14:56:28 Z zsombor Gap (APIO16_gap) C++17
89.0375 / 100
41 ms 4356 KB
#include "gap.h"
#include <vector>
using namespace std;
using ll = long long;

const ll m = 1000000000000000000;

ll solve1(ll n) {
	ll l = 0, r = m, mn, mx, ans = 0;
	vector <ll> v;
	vector <ll> v2;
	while (v.size() + v2.size() < n) {
		MinMax(l, r, &mn, &mx);
		l = mn + 1;
		r = mx - 1;
		v.push_back(mn);
		v2.push_back(mx);
	}
	while (v2.size()) { v.push_back(v2.back()); v2.pop_back(); }
	for (int i = 1; i < v.size(); i++) ans = max(ans, v[i] - v[i - 1]);
	return ans;
}

ll solve2(ll n) {
	ll a1, an, mn, mx, ans = 0;
	MinMax(0, m, &a1, &an);
	ll d = a1, u = a1, l = (an - a1) / (n - 1);
	vector <ll> v;
	while (d < an) {
		MinMax(d + 1, d + l, &mn, &mx);
		d += l;
		if (mn == -1) continue;
		ans = max(ans, mn - u);
		u = mx;
	}
	return ans;
}

ll findGap(int T, int N) {
	return (T == 1 ? solve1(N) : solve2(N));
}

Compilation message

gap.cpp: In function 'll solve1(ll)':
gap.cpp:12:30: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   12 |  while (v.size() + v2.size() < n) {
      |         ~~~~~~~~~~~~~~~~~~~~~^~~
gap.cpp:20:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for (int i = 1; i < v.size(); i++) ans = max(ans, v[i] - v[i - 1]);
      |                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 2388 KB Output is correct
3 Correct 0 ms 2392 KB Output is correct
4 Correct 0 ms 2392 KB Output is correct
5 Correct 0 ms 2392 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 0 ms 2392 KB Output is correct
9 Correct 0 ms 2392 KB Output is correct
10 Correct 1 ms 2392 KB Output is correct
11 Correct 1 ms 2392 KB Output is correct
12 Correct 0 ms 2392 KB Output is correct
13 Correct 1 ms 2392 KB Output is correct
14 Correct 0 ms 2392 KB Output is correct
15 Correct 1 ms 2392 KB Output is correct
16 Correct 5 ms 2904 KB Output is correct
17 Correct 5 ms 2904 KB Output is correct
18 Correct 6 ms 2904 KB Output is correct
19 Correct 6 ms 3052 KB Output is correct
20 Correct 4 ms 2904 KB Output is correct
21 Correct 25 ms 4348 KB Output is correct
22 Correct 22 ms 4240 KB Output is correct
23 Correct 23 ms 4356 KB Output is correct
24 Correct 28 ms 4220 KB Output is correct
25 Correct 23 ms 4220 KB Output is correct
26 Correct 24 ms 4220 KB Output is correct
27 Correct 25 ms 4288 KB Output is correct
28 Correct 26 ms 4220 KB Output is correct
29 Correct 23 ms 4216 KB Output is correct
30 Correct 20 ms 2684 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2392 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 2392 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 10 ms 636 KB Output is correct
17 Correct 7 ms 600 KB Output is correct
18 Correct 7 ms 608 KB Output is correct
19 Correct 10 ms 600 KB Output is correct
20 Partially correct 4 ms 600 KB Partially correct
21 Correct 36 ms 1024 KB Output is correct
22 Correct 28 ms 2648 KB Output is correct
23 Correct 29 ms 2840 KB Output is correct
24 Correct 39 ms 1108 KB Output is correct
25 Correct 32 ms 1112 KB Output is correct
26 Correct 39 ms 1364 KB Output is correct
27 Correct 29 ms 1112 KB Output is correct
28 Correct 41 ms 1140 KB Output is correct
29 Correct 39 ms 2648 KB Output is correct
30 Partially correct 20 ms 1112 KB Partially correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct