# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
536251 |
2022-03-12T16:38:12 Z |
terrasphere |
Gap (APIO16_gap) |
C++17 |
|
62 ms |
2040 KB |
#include "gap.h"
#include <bits/stdc++.h>
long long findGap(int T, int N)
{
long long arr[111111];
long long mn, mx;
long long tmp;
long long maximum;
long long high=1e18, low=0;
if(T==1)
{
for(int i=1;i<=N/2;i++)
{
MinMax(low,high,&mn,&mx);
arr[i]=mn;
arr[N-i+1]=mx;
low=mn+1;
high=mx-1;
}
if(N%2==1)
{
MinMax(low,high,&mn,&mx);
arr[N/2+1]=mn;
}
long long answer=0;
for(int i=2;i<=N;i++)
answer=std::max(answer,arr[i]-arr[i-1]);
return answer;
}
else
{
long long answer=0;
MinMax(low,high,&mn,&mx);
tmp=mn;
maximum=mx;
low=mn;
high=mx;
long long sz;
sz=(high-low+N-1)/N;
low++;
high--;
high=low+sz;
for(int i=0;i<N;i++)
{
MinMax(low+1,high,&mn,&mx);
low+=sz;
high+=sz;
if(mn==-1)
continue;
answer=std::max(answer,mn-tmp);
tmp=mx;
}
return answer;
}
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:9:15: warning: variable 'maximum' set but not used [-Wunused-but-set-variable]
9 | long long maximum;
| ^~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1104 KB |
Output is correct |
2 |
Correct |
1 ms |
1104 KB |
Output is correct |
3 |
Correct |
1 ms |
1104 KB |
Output is correct |
4 |
Correct |
1 ms |
1104 KB |
Output is correct |
5 |
Correct |
1 ms |
1104 KB |
Output is correct |
6 |
Correct |
1 ms |
1176 KB |
Output is correct |
7 |
Correct |
1 ms |
1104 KB |
Output is correct |
8 |
Correct |
1 ms |
1104 KB |
Output is correct |
9 |
Correct |
1 ms |
1104 KB |
Output is correct |
10 |
Correct |
1 ms |
1104 KB |
Output is correct |
11 |
Correct |
1 ms |
1104 KB |
Output is correct |
12 |
Correct |
1 ms |
1104 KB |
Output is correct |
13 |
Correct |
1 ms |
1104 KB |
Output is correct |
14 |
Correct |
2 ms |
1104 KB |
Output is correct |
15 |
Correct |
1 ms |
1104 KB |
Output is correct |
16 |
Correct |
10 ms |
1360 KB |
Output is correct |
17 |
Correct |
11 ms |
1360 KB |
Output is correct |
18 |
Correct |
9 ms |
1360 KB |
Output is correct |
19 |
Correct |
10 ms |
1384 KB |
Output is correct |
20 |
Correct |
8 ms |
1360 KB |
Output is correct |
21 |
Correct |
39 ms |
1824 KB |
Output is correct |
22 |
Correct |
40 ms |
1908 KB |
Output is correct |
23 |
Correct |
39 ms |
1828 KB |
Output is correct |
24 |
Correct |
47 ms |
1948 KB |
Output is correct |
25 |
Correct |
40 ms |
1896 KB |
Output is correct |
26 |
Correct |
37 ms |
1892 KB |
Output is correct |
27 |
Correct |
38 ms |
1948 KB |
Output is correct |
28 |
Correct |
40 ms |
1824 KB |
Output is correct |
29 |
Correct |
45 ms |
1944 KB |
Output is correct |
30 |
Correct |
36 ms |
1840 KB |
Output is correct |
31 |
Correct |
1 ms |
1104 KB |
Output is correct |
32 |
Correct |
1 ms |
1104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1104 KB |
Output is correct |
2 |
Correct |
1 ms |
1104 KB |
Output is correct |
3 |
Correct |
1 ms |
1104 KB |
Output is correct |
4 |
Correct |
1 ms |
1104 KB |
Output is correct |
5 |
Correct |
1 ms |
1104 KB |
Output is correct |
6 |
Correct |
1 ms |
1104 KB |
Output is correct |
7 |
Correct |
1 ms |
1104 KB |
Output is correct |
8 |
Correct |
1 ms |
1104 KB |
Output is correct |
9 |
Correct |
1 ms |
1104 KB |
Output is correct |
10 |
Correct |
1 ms |
1104 KB |
Output is correct |
11 |
Correct |
1 ms |
1104 KB |
Output is correct |
12 |
Correct |
1 ms |
1104 KB |
Output is correct |
13 |
Correct |
2 ms |
1104 KB |
Output is correct |
14 |
Correct |
2 ms |
1104 KB |
Output is correct |
15 |
Correct |
1 ms |
1104 KB |
Output is correct |
16 |
Correct |
15 ms |
1360 KB |
Output is correct |
17 |
Correct |
15 ms |
1380 KB |
Output is correct |
18 |
Correct |
14 ms |
1444 KB |
Output is correct |
19 |
Correct |
14 ms |
1272 KB |
Output is correct |
20 |
Correct |
8 ms |
1340 KB |
Output is correct |
21 |
Correct |
52 ms |
1944 KB |
Output is correct |
22 |
Correct |
54 ms |
1824 KB |
Output is correct |
23 |
Correct |
52 ms |
1892 KB |
Output is correct |
24 |
Correct |
54 ms |
1992 KB |
Output is correct |
25 |
Correct |
51 ms |
1896 KB |
Output is correct |
26 |
Correct |
62 ms |
1952 KB |
Output is correct |
27 |
Correct |
52 ms |
1952 KB |
Output is correct |
28 |
Correct |
55 ms |
1944 KB |
Output is correct |
29 |
Correct |
53 ms |
2040 KB |
Output is correct |
30 |
Correct |
30 ms |
1864 KB |
Output is correct |
31 |
Correct |
1 ms |
1104 KB |
Output is correct |
32 |
Correct |
1 ms |
1104 KB |
Output is correct |