# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
713204 |
2023-03-21T09:57:43 Z |
lam |
Gap (APIO16_gap) |
C++14 |
|
68 ms |
1864 KB |
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
#define ll long long
const int maxn = 1e5 + 10;
int n;
ll a[maxn];
ll sub1()
{
int l=1; int r=n;
ll s = 0; ll t = 1e18;
while (l<=r)
{
ll *mx, *mn;
ll mmax, mmin;
mx = &mmax; mn = &mmin;
// cerr<<l<<' '<<r<<' '<<s<<' '<<t<<endl;
MinMax(s,t,mn,mx);
s = (mmin)+1; t = (mmax)-1;
a[l++]=mmin;
a[r--]=mmax;
}
ll ans = 0;
for (int i=2; i<=n; i++)
{
if (ans<a[i]-a[i-1]) ans=a[i]-a[i-1];
}
return ans;
}
set<ll> b;
ll sub2()
{
ll s, t, mmin, mmax;
ll *mn, *mx;
mn = &mmin; mx = &mmax;
s=0; t=1e18;
MinMax(s,t,mn,mx);
ll l,r;
l=mmin; r=mmax;
ll L = mmax - mmin;
ll dist = L / (n-1);
ll ans = dist;
ll last = l;
ll last_max = -1;
// cerr<<dist<<endl;
for (int i=1; i<n; i++)
{
ll next = min(r, last + dist);
s = last; t = next;
MinMax(s,t,mn,mx);
if (mmin != -1)
{
// cerr<<last_max<<' '<<mmin<<' '<<mmax<<endl;
if (last_max != -1) ans = max(ans, mmin - last_max);
last_max = mmax;
}
last = next+1;
if (last > r) break;
}
return ans;
}
ll findGap(int T, int N)
{
n=N;
// cerr<<":>"<<endl;
if (T==1) return sub1();
else return sub2();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 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 |
1 ms |
208 KB |
Output is correct |
6 |
Correct |
1 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 |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
2 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 |
688 KB |
Output is correct |
17 |
Correct |
10 ms |
692 KB |
Output is correct |
18 |
Correct |
12 ms |
688 KB |
Output is correct |
19 |
Correct |
10 ms |
660 KB |
Output is correct |
20 |
Correct |
8 ms |
624 KB |
Output is correct |
21 |
Correct |
54 ms |
1796 KB |
Output is correct |
22 |
Correct |
41 ms |
1788 KB |
Output is correct |
23 |
Correct |
38 ms |
1800 KB |
Output is correct |
24 |
Correct |
41 ms |
1760 KB |
Output is correct |
25 |
Correct |
36 ms |
1800 KB |
Output is correct |
26 |
Correct |
38 ms |
1820 KB |
Output is correct |
27 |
Correct |
38 ms |
1752 KB |
Output is correct |
28 |
Correct |
38 ms |
1852 KB |
Output is correct |
29 |
Correct |
37 ms |
1864 KB |
Output is correct |
30 |
Correct |
30 ms |
1776 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 |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
1 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 |
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 |
13 ms |
528 KB |
Output is correct |
17 |
Correct |
14 ms |
432 KB |
Output is correct |
18 |
Correct |
13 ms |
528 KB |
Output is correct |
19 |
Correct |
13 ms |
500 KB |
Output is correct |
20 |
Correct |
8 ms |
492 KB |
Output is correct |
21 |
Correct |
68 ms |
1088 KB |
Output is correct |
22 |
Correct |
61 ms |
1104 KB |
Output is correct |
23 |
Correct |
55 ms |
1088 KB |
Output is correct |
24 |
Correct |
61 ms |
1084 KB |
Output is correct |
25 |
Correct |
55 ms |
976 KB |
Output is correct |
26 |
Correct |
58 ms |
1088 KB |
Output is correct |
27 |
Correct |
56 ms |
1088 KB |
Output is correct |
28 |
Correct |
54 ms |
1064 KB |
Output is correct |
29 |
Correct |
62 ms |
988 KB |
Output is correct |
30 |
Correct |
35 ms |
1080 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |