# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
778922 |
2023-07-11T03:10:44 Z |
horiiseun |
Gap (APIO16_gap) |
C++17 |
|
47 ms |
1856 KB |
#include <iostream>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
#include <cmath>
#include <random>
#include <string>
#include <bitset>
#include <cassert>
#include <climits>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include "gap.h"
using namespace std;
#define ll long long
#define f first
#define s second
void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }
template<typename A> void __print(const A &x);
template<typename A, typename B> void __print(const pair<A, B> &p);
template<typename... A> void __print(const tuple<A...> &t);
template<typename T> void __print(stack<T> s);
template<typename T> void __print(queue<T> q);
template<typename T, typename... U> void __print(priority_queue<T, U...> q);
template<typename A> void __print(const A &x) {
bool first = true;
cerr << '{';
for (const auto &i : x) {
cerr << (first ? "" : ","), __print(i);
first = false;
}
cerr << '}';
}
template<typename A, typename B> void __print(const pair<A, B> &p) {
cerr << '(';
__print(p.f);
cerr << ',';
__print(p.s);
cerr << ')';
}
template<typename... A> void __print(const tuple<A...> &t) {
bool first = true;
cerr << '(';
apply([&first] (const auto &...args) { ((cerr << (first ? "" : ","), __print(args), first = false), ...); }, t);
cerr << ')';
}
template<typename T> void __print(stack<T> s) {
vector<T> debugVector;
while (!s.empty()) {
T t = s.top();
debugVector.push_back(t);
s.pop();
}
reverse(debugVector.begin(), debugVector.end());
__print(debugVector);
}
template<typename T> void __print(queue<T> q) {
vector<T> debugVector;
while (!q.empty()) {
T t = q.front();
debugVector.push_back(t);
q.pop();
}
__print(debugVector);
}
template<typename T, typename... U> void __print(priority_queue<T, U...> q) {
vector<T> debugVector;
while (!q.empty()) {
T t = q.top();
debugVector.push_back(t);
q.pop();
}
__print(debugVector);
}
void _print() { cerr << "]\n"; }
template <typename Head, typename... Tail> void _print(const Head &H, const Tail &...T) {
__print(H);
if (sizeof...(T)) cerr << ", ";
_print(T...);
}
#ifdef DEBUG
#define D(...) cerr << "Line: " << __LINE__ << " [" << #__VA_ARGS__ << "] = ["; _print(__VA_ARGS__)
#else
#define D(...)
#endif
#define ll long long
ll findGap(int T, int N) {
ll mn, mx, sm = 1, lg = 1e18, ans = 0;
if (T == 1) {
vector<ll> v(N, 0);
for (int i = 0; i < (N + 1) / 2; i++) {
MinMax(sm, lg, &mn, &mx);
v[i] = mn;
v[N - i - 1] = mx;
sm = mn + 1;
lg = mx - 1;
}
for (int i = 1; i < N; i++) {
ans = max(ans, v[i] - v[i - 1]);
}
return ans;
}
MinMax(sm, lg, &mn, &mx);
ll gap = (mx - mn) / (N - 1) + 1, tmn, tmx, lst = mn;
for (sm = mn + 1, lg = sm + gap; sm < mx; sm += gap, lg += gap) {
if (sm >= mx) break;
lg = min(lg, mx);
MinMax(sm, lg - 1, &tmn, &tmx);
if (!(tmn == -1 && tmx == -1)) {
ans = max(ans, tmn - lst);
lst = tmx;
}
}
ans = max(ans, mx - lst);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
1 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 |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 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 |
9 ms |
720 KB |
Output is correct |
17 |
Correct |
8 ms |
628 KB |
Output is correct |
18 |
Correct |
10 ms |
708 KB |
Output is correct |
19 |
Correct |
7 ms |
720 KB |
Output is correct |
20 |
Correct |
6 ms |
592 KB |
Output is correct |
21 |
Correct |
30 ms |
1832 KB |
Output is correct |
22 |
Correct |
29 ms |
1856 KB |
Output is correct |
23 |
Correct |
34 ms |
1836 KB |
Output is correct |
24 |
Correct |
29 ms |
1824 KB |
Output is correct |
25 |
Correct |
26 ms |
1828 KB |
Output is correct |
26 |
Correct |
29 ms |
1820 KB |
Output is correct |
27 |
Correct |
30 ms |
1792 KB |
Output is correct |
28 |
Correct |
32 ms |
1832 KB |
Output is correct |
29 |
Correct |
35 ms |
1820 KB |
Output is correct |
30 |
Correct |
26 ms |
1768 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
1 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 |
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 |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
10 ms |
520 KB |
Output is correct |
17 |
Correct |
10 ms |
424 KB |
Output is correct |
18 |
Correct |
11 ms |
516 KB |
Output is correct |
19 |
Correct |
10 ms |
508 KB |
Output is correct |
20 |
Correct |
5 ms |
464 KB |
Output is correct |
21 |
Correct |
42 ms |
1084 KB |
Output is correct |
22 |
Correct |
46 ms |
1060 KB |
Output is correct |
23 |
Correct |
46 ms |
968 KB |
Output is correct |
24 |
Correct |
40 ms |
1060 KB |
Output is correct |
25 |
Correct |
43 ms |
972 KB |
Output is correct |
26 |
Correct |
47 ms |
976 KB |
Output is correct |
27 |
Correct |
43 ms |
968 KB |
Output is correct |
28 |
Correct |
40 ms |
984 KB |
Output is correct |
29 |
Correct |
42 ms |
1076 KB |
Output is correct |
30 |
Correct |
22 ms |
1132 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |