# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
943890 |
2024-03-12T03:41:36 Z |
Boycl07 |
Gap (APIO16_gap) |
C++17 |
|
45 ms |
3876 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 1; (i) <= (n); ++i)
#define forn(i, l, r) for(int i = (l); i <= (r); ++i)
#define ford(i, r, l) for(int i = (r); i >= (l); --i)
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define FORD(i, n) for(int i = ((n) - 1); i >= 0; --i)
#define fi first
#define se second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define endl "\n"
#define task "firework"
#define sz(a) int(a.size())
#define C(x, y) make_pair(x, y)
#define all(a) (a).begin(), (a).end()
#define bit(i, mask) (mask >> i & 1)
template<typename T> bool maximize(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; }
template<typename T> bool minimize(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; }
inline int readInt() {char c;while(c=getchar(),c!='-'&&(c<'0'||c>'9'));bool sign=(c=='-');if(sign)c=getchar();int n=c-'0';while(c=getchar(),c>='0'&&c<='9')n=10*n+c-'0';return(!sign)?n:-n;}
inline ll readLong() {char c;while(c=getchar(),c!='-'&&(c<'0'||c>'9'));bool sign=(c=='-');if(sign)c=getchar();ll n=c-'0';while(c=getchar(),c>='0'&&c<='9')n=10*n+c-'0';return(!sign)?n:-n;}
inline string readString() {char c;while(c=getchar(),c==' '||c=='\n'||c=='\t');string s({c});while(c=getchar(),c!=EOF&&c!=' '&&c!='\n'&&c!='\t')s+=c;return s;}
static int subtask_num, N;
static long long A[100001];
static long long call_count;
void MinMax(long long, long long, long long*, long long*);
ll findGap(int T, int N)
{
vector<ll> a(N + 2);
if(T == 1)
{
int l = 1, r = N;
ll lb = 0, rb = 1e18;
while(l <= r)
{
ll x, y;
MinMax(lb, rb, &a[l], &a[r]);
lb = a[l++] + 1;
rb = a[r--] - 1;
}
ll res = 0;
rep(i, N - 1) maximize(res, a[i + 1] - a[i]);
return res;
}
ll x, y;
MinMax(0, 1e18, &x, &y);
a[1] = x, a[N] = y;
ll res = 0;
ll Min_step = (a[N] - a[1] - 1) / (N - 1) + 1;
if(N == 2) return a[N] - a[1];
for(ll i = a[1], pre = a[1]; i <= a[N]; i += Min_step + 1)
{
MinMax(i, i + Min_step, &x, &y);
if(x != -1) maximize(res, x - pre), pre = y;
}
return res;
}
Compilation message
gap.cpp: In function 'll findGap(int, int)':
gap.cpp:47:16: warning: unused variable 'x' [-Wunused-variable]
47 | ll x, y;
| ^
gap.cpp:47:19: warning: unused variable 'y' [-Wunused-variable]
47 | ll x, y;
| ^
gap.cpp: At global scope:
gap.cpp:34:18: warning: 'call_count' defined but not used [-Wunused-variable]
34 | static long long call_count;
| ^~~~~~~~~~
gap.cpp:33:18: warning: 'A' defined but not used [-Wunused-variable]
33 | static long long A[100001];
| ^
gap.cpp:32:25: warning: 'N' defined but not used [-Wunused-variable]
32 | static int subtask_num, N;
| ^
gap.cpp:32:12: warning: 'subtask_num' defined but not used [-Wunused-variable]
32 | static int subtask_num, N;
| ^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
0 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2392 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
0 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
0 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
8 ms |
2656 KB |
Output is correct |
17 |
Correct |
8 ms |
2588 KB |
Output is correct |
18 |
Correct |
8 ms |
2592 KB |
Output is correct |
19 |
Correct |
9 ms |
2680 KB |
Output is correct |
20 |
Correct |
7 ms |
2568 KB |
Output is correct |
21 |
Correct |
30 ms |
3604 KB |
Output is correct |
22 |
Correct |
30 ms |
3616 KB |
Output is correct |
23 |
Correct |
31 ms |
3624 KB |
Output is correct |
24 |
Correct |
30 ms |
3624 KB |
Output is correct |
25 |
Correct |
27 ms |
3784 KB |
Output is correct |
26 |
Correct |
31 ms |
3624 KB |
Output is correct |
27 |
Correct |
30 ms |
3624 KB |
Output is correct |
28 |
Correct |
31 ms |
3864 KB |
Output is correct |
29 |
Correct |
31 ms |
3624 KB |
Output is correct |
30 |
Correct |
25 ms |
3872 KB |
Output is correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2392 KB |
Output is correct |
4 |
Correct |
0 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 ms |
2388 KB |
Output is correct |
7 |
Correct |
1 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 ms |
2392 KB |
Output is correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Correct |
1 ms |
2392 KB |
Output is correct |
13 |
Correct |
1 ms |
2392 KB |
Output is correct |
14 |
Correct |
1 ms |
2392 KB |
Output is correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
10 ms |
2588 KB |
Output is correct |
17 |
Correct |
10 ms |
2820 KB |
Output is correct |
18 |
Correct |
12 ms |
2584 KB |
Output is correct |
19 |
Correct |
10 ms |
2752 KB |
Output is correct |
20 |
Correct |
6 ms |
2572 KB |
Output is correct |
21 |
Correct |
41 ms |
3876 KB |
Output is correct |
22 |
Correct |
41 ms |
3624 KB |
Output is correct |
23 |
Correct |
41 ms |
3624 KB |
Output is correct |
24 |
Correct |
41 ms |
3628 KB |
Output is correct |
25 |
Correct |
39 ms |
3620 KB |
Output is correct |
26 |
Correct |
45 ms |
3556 KB |
Output is correct |
27 |
Correct |
41 ms |
3628 KB |
Output is correct |
28 |
Correct |
41 ms |
3620 KB |
Output is correct |
29 |
Correct |
44 ms |
3624 KB |
Output is correct |
30 |
Correct |
23 ms |
3624 KB |
Output is correct |
31 |
Correct |
0 ms |
2392 KB |
Output is correct |
32 |
Correct |
1 ms |
2392 KB |
Output is correct |