Submission #507532

# Submission time Handle Problem Language Result Execution time Memory
507532 2022-01-12T16:45:43 Z keta_tsimakuridze Gap (APIO16_gap) C++14
100 / 100
59 ms 2744 KB
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
#define ll long long

long long findGap(int T, int n)
{
	ll L = 0, R = 1e18;
	if(T == 1) {
		vector<ll> p, s;
		int cnt = 0;
		while(cnt < n) {
			ll mn = 0, mx = 0;
			MinMax(L, R, &mn, &mx); cnt += 2;
			if(mn == -1) break;
			p.push_back(mn); s.push_back(mx);
			L = mn + 1; R = mx - 1;
		}
		for(int j = (int)s.size() - 1; j >= 0; j--) p.push_back(s[j]);
		ll ans = 0;
		for(int j = 1; j < p.size(); j++) ans = max(ans, p[j] - p[j - 1]);
		return ans;
	}
		ll mn = 0, mx = 0, Mx = 0;
		MinMax(L, R, &mn, &mx); Mx = mx;
		ll x = (mx  - mn + n - 1) / n, ans = x;
		ll last = mn, cur = mn + 1;
		while(cur <= Mx) {
			MinMax(cur, cur + x, &mn, &mx);
			ans = max(ans, mn - last);
			if(mx != -1) last = mx;
			cur += x + 1;
		}
		return ans;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:21:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   for(int j = 1; j < p.size(); j++) ans = max(ans, p[j] - p[j - 1]);
      |                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 0 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 0 ms 200 KB Output is correct
9 Correct 0 ms 200 KB Output is correct
10 Correct 0 ms 200 KB Output is correct
11 Correct 1 ms 328 KB Output is correct
12 Correct 2 ms 328 KB Output is correct
13 Correct 1 ms 328 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 328 KB Output is correct
16 Correct 10 ms 972 KB Output is correct
17 Correct 10 ms 920 KB Output is correct
18 Correct 10 ms 968 KB Output is correct
19 Correct 9 ms 968 KB Output is correct
20 Correct 10 ms 976 KB Output is correct
21 Correct 43 ms 2532 KB Output is correct
22 Correct 36 ms 2744 KB Output is correct
23 Correct 42 ms 2632 KB Output is correct
24 Correct 40 ms 2580 KB Output is correct
25 Correct 33 ms 2640 KB Output is correct
26 Correct 38 ms 2620 KB Output is correct
27 Correct 38 ms 2600 KB Output is correct
28 Correct 39 ms 2616 KB Output is correct
29 Correct 35 ms 2608 KB Output is correct
30 Correct 30 ms 2584 KB Output is correct
31 Correct 0 ms 200 KB Output is correct
32 Correct 0 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 0 ms 200 KB Output is correct
4 Correct 0 ms 200 KB Output is correct
5 Correct 0 ms 200 KB Output is correct
6 Correct 0 ms 200 KB Output is correct
7 Correct 0 ms 200 KB Output is correct
8 Correct 0 ms 200 KB Output is correct
9 Correct 1 ms 200 KB Output is correct
10 Correct 1 ms 200 KB Output is correct
11 Correct 1 ms 200 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 2 ms 328 KB Output is correct
14 Correct 1 ms 328 KB Output is correct
15 Correct 1 ms 200 KB Output is correct
16 Correct 12 ms 456 KB Output is correct
17 Correct 13 ms 416 KB Output is correct
18 Correct 14 ms 408 KB Output is correct
19 Correct 12 ms 504 KB Output is correct
20 Correct 6 ms 456 KB Output is correct
21 Correct 56 ms 1080 KB Output is correct
22 Correct 46 ms 1044 KB Output is correct
23 Correct 49 ms 1076 KB Output is correct
24 Correct 49 ms 1072 KB Output is correct
25 Correct 44 ms 968 KB Output is correct
26 Correct 50 ms 1180 KB Output is correct
27 Correct 56 ms 1056 KB Output is correct
28 Correct 50 ms 968 KB Output is correct
29 Correct 59 ms 1056 KB Output is correct
30 Correct 27 ms 1060 KB Output is correct
31 Correct 0 ms 200 KB Output is correct
32 Correct 1 ms 200 KB Output is correct