# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
388576 |
2021-04-12T07:19:25 Z |
talant117408 |
Gap (APIO16_gap) |
C++17 |
|
67 ms |
2300 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define mp make_pair
#define eps (double)1e-9
#define PI 2*acos(0.0)
#define endl "\n"
#define sz(v) int((v).size())
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll findGap(int T, int n) {
if (T == 1) {
vector <ll> v;
ll l = 1, r = 1e18;
ll mn = 0, mx = 0;
while (l <= r) {
if (sz(v) == n) break;
MinMax(l, r, &mn, &mx);
if (mn == -1 && mx == -1) {
break;
}
v.pb(mn);
if (mn != mx) v.pb(mx);
l = mn+1; r = mx-1;
}
sort(all(v));
ll ans = 0;
for (int i = 0; i < n-1; i++) ans = max(ans, v[i+1]-v[i]);
return ans;
}
else {
vector <ll> v;
ll mn, mx;
MinMax(0, 1e18, &mn, &mx);
ll k = (mx-mn+n-2)/(n-1);
v.pb(mn); v.pb(mx);
ll MN = mn, MX = mx;
for (ll i = MN+1; i <= MX-1; i += k) {
MinMax(i, min(MX-1, i+k-1), &mn, &mx);
if (mn != -1 && mx != -1) {
if (mn == mx) {
v.pb(mn);
}
else {
v.pb(mn); v.pb(mx);
}
}
}
sort(all(v));
ll ans = 0;
for (int i = 0; i < sz(v)-1; i++) ans = max(ans, v[i+1]-v[i]);
return ans;
}
}
# |
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 |
1 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 |
1 ms |
328 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
1 ms |
448 KB |
Output is correct |
15 |
Correct |
1 ms |
328 KB |
Output is correct |
16 |
Correct |
12 ms |
840 KB |
Output is correct |
17 |
Correct |
12 ms |
840 KB |
Output is correct |
18 |
Correct |
12 ms |
840 KB |
Output is correct |
19 |
Correct |
12 ms |
840 KB |
Output is correct |
20 |
Correct |
10 ms |
840 KB |
Output is correct |
21 |
Correct |
49 ms |
2156 KB |
Output is correct |
22 |
Correct |
54 ms |
2184 KB |
Output is correct |
23 |
Correct |
50 ms |
2196 KB |
Output is correct |
24 |
Correct |
48 ms |
2184 KB |
Output is correct |
25 |
Correct |
43 ms |
2232 KB |
Output is correct |
26 |
Correct |
48 ms |
2128 KB |
Output is correct |
27 |
Correct |
49 ms |
2196 KB |
Output is correct |
28 |
Correct |
47 ms |
2136 KB |
Output is correct |
29 |
Correct |
52 ms |
2204 KB |
Output is correct |
30 |
Correct |
39 ms |
2228 KB |
Output is correct |
31 |
Correct |
1 ms |
200 KB |
Output is correct |
32 |
Correct |
1 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 |
1 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 |
2 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 |
16 ms |
892 KB |
Output is correct |
17 |
Correct |
16 ms |
804 KB |
Output is correct |
18 |
Correct |
15 ms |
840 KB |
Output is correct |
19 |
Correct |
16 ms |
908 KB |
Output is correct |
20 |
Correct |
7 ms |
456 KB |
Output is correct |
21 |
Correct |
62 ms |
2232 KB |
Output is correct |
22 |
Correct |
62 ms |
2184 KB |
Output is correct |
23 |
Correct |
63 ms |
2300 KB |
Output is correct |
24 |
Correct |
64 ms |
2188 KB |
Output is correct |
25 |
Correct |
63 ms |
2232 KB |
Output is correct |
26 |
Correct |
64 ms |
2200 KB |
Output is correct |
27 |
Correct |
64 ms |
2236 KB |
Output is correct |
28 |
Correct |
62 ms |
2232 KB |
Output is correct |
29 |
Correct |
67 ms |
2232 KB |
Output is correct |
30 |
Correct |
33 ms |
1404 KB |
Output is correct |
31 |
Correct |
0 ms |
200 KB |
Output is correct |
32 |
Correct |
1 ms |
200 KB |
Output is correct |