Submission #197003

# Submission time Handle Problem Language Result Execution time Memory
197003 2020-01-18T03:58:40 Z Juney Gap (APIO16_gap) C++14
100 / 100
82 ms 2292 KB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

void f(ll s, ll t, ll &a, ll &b) { MinMax(s, t, &a, &b); }

ll findGap(int T, int N) {
	if(T == 1) {
		ll l = 0, r = 1e18;
		vector<ll> v;
		for(int i=1; i<=(N+1)/2; i++) {
			if(l > r) break;
			ll a, b; f(l, r, a, b);
			if(a != -1) v.push_back(a);
			if(b != -1 && a != b) v.push_back(b);
			l = a + 1; r = b - 1;
		}
		sort(v.begin(), v.end());
		ll ans = 0;
		for(int i=1; i<v.size(); i++) ans = max(ans, v[i] - v[i-1]);
		return ans;
	}
	else {
		ll l, r;
		f(0, (ll)1e18, l, r);
		ll sz = (r - l) / (N-1);
		ll s = l, e = l + sz;
		vector<ll> v;
		for(int i=1; i<=N-1; i++) {
			if(s > e) break;
			ll a, b; f(s, e, a, b);
			if(a != -1) v.push_back(a);
			if(b != -1 && a != b) v.push_back(b);
			s = e + 1; e = min(r, s + sz);
		}
		ll ans = 0;
		for(int i=1; i<v.size(); i++) ans = max(ans, v[i] - v[i-1]);
		return ans;
	}
}

Compilation message

gap.cpp: In function 'll findGap(int, int)':
gap.cpp:22:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=1; i<v.size(); i++) ans = max(ans, v[i] - v[i-1]);
                ~^~~~~~~~~
gap.cpp:39:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=1; i<v.size(); i++) ans = max(ans, v[i] - v[i-1]);
                ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 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 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 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 376 KB Output is correct
16 Correct 18 ms 1016 KB Output is correct
17 Correct 17 ms 888 KB Output is correct
18 Correct 18 ms 1016 KB Output is correct
19 Correct 17 ms 888 KB Output is correct
20 Correct 13 ms 888 KB Output is correct
21 Correct 63 ms 2288 KB Output is correct
22 Correct 62 ms 2284 KB Output is correct
23 Correct 61 ms 2248 KB Output is correct
24 Correct 62 ms 2228 KB Output is correct
25 Correct 54 ms 2288 KB Output is correct
26 Correct 61 ms 2292 KB Output is correct
27 Correct 62 ms 2284 KB Output is correct
28 Correct 62 ms 2284 KB Output is correct
29 Correct 62 ms 2288 KB Output is correct
30 Correct 48 ms 2260 KB Output is correct
31 Correct 3 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 0 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 348 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 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 11 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 22 ms 888 KB Output is correct
17 Correct 22 ms 888 KB Output is correct
18 Correct 21 ms 1016 KB Output is correct
19 Correct 21 ms 888 KB Output is correct
20 Correct 11 ms 632 KB Output is correct
21 Correct 82 ms 2288 KB Output is correct
22 Correct 79 ms 2284 KB Output is correct
23 Correct 79 ms 2268 KB Output is correct
24 Correct 78 ms 2292 KB Output is correct
25 Correct 75 ms 2288 KB Output is correct
26 Correct 79 ms 2284 KB Output is correct
27 Correct 78 ms 2288 KB Output is correct
28 Correct 79 ms 2284 KB Output is correct
29 Correct 79 ms 2288 KB Output is correct
30 Correct 40 ms 1568 KB Output is correct
31 Correct 2 ms 376 KB Output is correct
32 Correct 2 ms 376 KB Output is correct