# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
612437 |
2022-07-29T15:01:09 Z |
thezomb1e |
Gap (APIO16_gap) |
C++17 |
|
70 ms |
2244 KB |
#include "gap.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define ft first
#define sd second
#define pi pair<int, int>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dbg(...) dbg_out(__VA_ARGS__)
using ll = long long;
using ld = long double;
using namespace std;
using namespace __gnu_pbds;
//Constants
const ll INF = 5 * 1e18;
const int IINF = 2 * 1e9;
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ld PI = 3.14159265359;
//Templates
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) {return os << '(' << p.first << ", " << p.second << ')';}
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) {os << '['; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << ']';}
void dbg_out() {cerr << endl;}
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << H << ' '; dbg_out(T...); }
template<typename T> void mins(T& x, T y) {x = min(x, y);}
template<typename T> void maxs(T& x, T y) {x = max(x, y);}
template<typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using omset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll MAX = 1e18;
ll findGap(int t, int n) {
if (t == 1) {
ll mn, mx, l = 1, r = MAX;
vector<ll> a;
for (int i = 0; i < (n + 1) / 2; i++) {
MinMax(l, r, &mn, &mx);
if (mn != mx) a.pb(mx);
a.pb(mn);
l = mn + 1; r = mx - 1;
}
sort(all(a));
ll ans = -INF;
for (int i = 1; i < (int) a.size(); i++) {
maxs(ans, a[i] - a[i - 1]);
}
return ans;
} else {
ll mn, mx; ll big;
MinMax(1, MAX, &mn, &mx);
big = mx;
ll lb = (mx - mn + n - 2) / (n - 1);
ll i = mn, ans = lb, last = -1;
while (i <= big) {
MinMax(i, i + lb, &mn, &mx);
if (mn != -1) {
if (last != -1) {
maxs(ans, mn - last);
}
last = mx;
}
i += lb + 1;
}
return ans;
}
}
# |
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 |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
1 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 |
2 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
12 ms |
848 KB |
Output is correct |
17 |
Correct |
12 ms |
824 KB |
Output is correct |
18 |
Correct |
11 ms |
848 KB |
Output is correct |
19 |
Correct |
12 ms |
812 KB |
Output is correct |
20 |
Correct |
8 ms |
848 KB |
Output is correct |
21 |
Correct |
44 ms |
2216 KB |
Output is correct |
22 |
Correct |
37 ms |
2204 KB |
Output is correct |
23 |
Correct |
38 ms |
2204 KB |
Output is correct |
24 |
Correct |
50 ms |
2204 KB |
Output is correct |
25 |
Correct |
39 ms |
2208 KB |
Output is correct |
26 |
Correct |
38 ms |
2244 KB |
Output is correct |
27 |
Correct |
40 ms |
2236 KB |
Output is correct |
28 |
Correct |
39 ms |
2180 KB |
Output is correct |
29 |
Correct |
43 ms |
2216 KB |
Output is correct |
30 |
Correct |
34 ms |
2204 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 |
1 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 |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
12 ms |
420 KB |
Output is correct |
17 |
Correct |
12 ms |
520 KB |
Output is correct |
18 |
Correct |
12 ms |
500 KB |
Output is correct |
19 |
Correct |
15 ms |
500 KB |
Output is correct |
20 |
Correct |
6 ms |
464 KB |
Output is correct |
21 |
Correct |
49 ms |
968 KB |
Output is correct |
22 |
Correct |
68 ms |
1060 KB |
Output is correct |
23 |
Correct |
47 ms |
968 KB |
Output is correct |
24 |
Correct |
52 ms |
1048 KB |
Output is correct |
25 |
Correct |
49 ms |
992 KB |
Output is correct |
26 |
Correct |
51 ms |
1080 KB |
Output is correct |
27 |
Correct |
52 ms |
1084 KB |
Output is correct |
28 |
Correct |
67 ms |
1048 KB |
Output is correct |
29 |
Correct |
70 ms |
1080 KB |
Output is correct |
30 |
Correct |
30 ms |
964 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
1 ms |
208 KB |
Output is correct |