Submission #598340

# Submission time Handle Problem Language Result Execution time Memory
598340 2022-07-18T06:01:08 Z 8e7 Gap (APIO16_gap) C++17
100 / 100
61 ms 3260 KB
//Challenge: Accepted
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
#ifdef zisk
void debug(){cout << endl;}
template<class T, class ... U> void debug(T a, U ... b){cout << a << " ", debug(b...);}
template<class T> void pary(T l, T r) {
	while (l != r) cout << *l << " ", l++;
	cout << endl;
}
#else
#define debug(...) 0
#define pary(...) 0
#endif
#define ll long long
#define maxn 50005
#define pii pair<int, int>
#define ff first
#define ss second
#define io ios_base::sync_with_stdio(0);cin.tie(0);
const ll inf = 1e18;
ll findGap(int T, int N) {
	ll ret = 0;
	vector<ll> a;
	if (T == 1) {
		ll low = 0, up = inf, vl, vr;
		while (low < up && a.size() < N) {
			MinMax(low, up, &vl, &vr);
			if (vl == -1) break;
			a.push_back(vl);
			a.push_back(vr);
			low = vl+1, up = vr-1;
		}
	} else {
		ll mi, ma;	
		MinMax(0, inf, &mi, &ma);
		a.push_back(mi);
		ll lef = mi+1;
		for (int i = 0;i < N-1;i++) {
			ll d = (ma - lef) / (N - 1 - i);
			ll rig = lef + d - 1, vl, vr;
			MinMax(lef, rig, &vl, &vr);
			lef += d;
			if (vl != -1) {
				a.push_back(vl);
				a.push_back(vr);
			}
		}
		a.push_back(ma);
	}
	sort(a.begin(), a.end());
	a.resize(int(unique(a.begin(), a.end()) - a.begin()));
	for (int i = 1;i < a.size();i++) ret = max(ret, a[i] - a[i-1]);
	return ret;
}

Compilation message

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:29:31: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |   while (low < up && a.size() < N) {
      |                      ~~~~~~~~~^~~
gap.cpp:55:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |  for (int i = 1;i < a.size();i++) ret = max(ret, a[i] - a[i-1]);
      |                 ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 11 ms 908 KB Output is correct
17 Correct 9 ms 888 KB Output is correct
18 Correct 12 ms 816 KB Output is correct
19 Correct 10 ms 812 KB Output is correct
20 Correct 9 ms 848 KB Output is correct
21 Correct 38 ms 2232 KB Output is correct
22 Correct 37 ms 2208 KB Output is correct
23 Correct 39 ms 2184 KB Output is correct
24 Correct 40 ms 2204 KB Output is correct
25 Correct 39 ms 2240 KB Output is correct
26 Correct 39 ms 2140 KB Output is correct
27 Correct 43 ms 2152 KB Output is correct
28 Correct 39 ms 2224 KB Output is correct
29 Correct 41 ms 2244 KB Output is correct
30 Correct 35 ms 2224 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 13 ms 848 KB Output is correct
17 Correct 12 ms 848 KB Output is correct
18 Correct 13 ms 808 KB Output is correct
19 Correct 14 ms 812 KB Output is correct
20 Correct 6 ms 484 KB Output is correct
21 Correct 52 ms 2248 KB Output is correct
22 Correct 53 ms 2244 KB Output is correct
23 Correct 55 ms 2256 KB Output is correct
24 Correct 52 ms 2200 KB Output is correct
25 Correct 49 ms 3260 KB Output is correct
26 Correct 59 ms 2204 KB Output is correct
27 Correct 57 ms 2212 KB Output is correct
28 Correct 61 ms 2168 KB Output is correct
29 Correct 55 ms 2192 KB Output is correct
30 Correct 27 ms 1372 KB Output is correct
31 Correct 0 ms 208 KB Output is correct
32 Correct 0 ms 208 KB Output is correct