# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1111121 |
2024-11-11T14:36:04 Z |
imarn |
Gap (APIO16_gap) |
C++14 |
|
2000 ms |
3668 KB |
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define plx pair<ll,int>
#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vvi vector<vi>
#define pp pair<ll,int>
#define ub(x,i) upper_bound(all(x),i)-x.begin()
using namespace std;
ll b[1005];
int m;
void MinMax(ll a,ll c,ll &t,ll &r){
t=-1,r=-1;
for(int i=0;i<m;i++){
if(t==-1&&b[i]>=a&&b[i]<=c)t=b[i];
if(b[i]>=a&&b[i]<=c)r=b[i];
}
}
long long cal1(int n){
ll a[n];
ll l=0,r=n-1;
ll mn=0,mx=0;
ll tl=0,tr=1e18;
while(l<=r){
MinMax(tl,tr,a[l],a[r]);
tl=a[l]+1,tr=a[r]-1;
l++,r--;
}ll rs=0;
for(int i=1;i<n;i++)rs=max(rs,a[i]-a[i-1]);
return rs;
}
ll cal2(int n){
ll mn,mx;
ll tl=0,tr=1e18;
MinMax(tl,tr,mn,mx);
ll ans = (mx-mn-1)/(n-1)+1;
ll cl=-1,cr=-1;
ll rl = mn+1,rr=mn+ans;
while(1){
MinMax(rl,rr,cl,cr);
if(cl==-1){
rl = rr+1;
rr = rr+ans;
}
else {
ans = max(ans,cl-mn);
mn=cr;
rl=rr+1;
rr=rr+ans;
if(cr==mx)break;
}
}return ans;
}
long long findGap(int T, int N)
{
if(T==1)return cal1(N);
else return cal2(N);
}
/*int main(){m=5;
b[0]=2;
b[1]=3;
b[2]=6;
b[3]=500;
b[4]=10000;
cout<<findGap(2,5);
}*/
Compilation message
gap.cpp: In function 'long long int cal1(int)':
gap.cpp:27:8: warning: unused variable 'mn' [-Wunused-variable]
27 | ll mn=0,mx=0;
| ^~
gap.cpp:27:13: warning: unused variable 'mx' [-Wunused-variable]
27 | ll mn=0,mx=0;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
2552 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
7 |
Incorrect |
1 ms |
2552 KB |
Output isn't correct |
8 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
9 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
10 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
11 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
12 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
13 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
14 |
Incorrect |
2 ms |
2384 KB |
Output isn't correct |
15 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
16 |
Incorrect |
7 ms |
2640 KB |
Output isn't correct |
17 |
Incorrect |
7 ms |
2640 KB |
Output isn't correct |
18 |
Incorrect |
7 ms |
2640 KB |
Output isn't correct |
19 |
Incorrect |
6 ms |
2640 KB |
Output isn't correct |
20 |
Incorrect |
4 ms |
2640 KB |
Output isn't correct |
21 |
Incorrect |
15 ms |
3408 KB |
Output isn't correct |
22 |
Incorrect |
15 ms |
3408 KB |
Output isn't correct |
23 |
Incorrect |
16 ms |
3420 KB |
Output isn't correct |
24 |
Incorrect |
25 ms |
3468 KB |
Output isn't correct |
25 |
Incorrect |
17 ms |
3420 KB |
Output isn't correct |
26 |
Incorrect |
15 ms |
3524 KB |
Output isn't correct |
27 |
Incorrect |
16 ms |
3668 KB |
Output isn't correct |
28 |
Incorrect |
16 ms |
3408 KB |
Output isn't correct |
29 |
Incorrect |
16 ms |
3408 KB |
Output isn't correct |
30 |
Incorrect |
9 ms |
3408 KB |
Output isn't correct |
31 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
32 |
Incorrect |
1 ms |
2384 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3060 ms |
2384 KB |
Time limit exceeded |
2 |
Execution timed out |
3054 ms |
2384 KB |
Time limit exceeded |
3 |
Execution timed out |
3054 ms |
2384 KB |
Time limit exceeded |
4 |
Execution timed out |
3054 ms |
2384 KB |
Time limit exceeded |
5 |
Execution timed out |
3066 ms |
2384 KB |
Time limit exceeded |
6 |
Execution timed out |
3065 ms |
2384 KB |
Time limit exceeded |
7 |
Execution timed out |
3083 ms |
2384 KB |
Time limit exceeded |
8 |
Execution timed out |
3078 ms |
2384 KB |
Time limit exceeded |
9 |
Execution timed out |
3059 ms |
2384 KB |
Time limit exceeded |
10 |
Execution timed out |
3058 ms |
2384 KB |
Time limit exceeded |
11 |
Execution timed out |
3067 ms |
2384 KB |
Time limit exceeded |
12 |
Execution timed out |
3064 ms |
2384 KB |
Time limit exceeded |
13 |
Execution timed out |
3062 ms |
2384 KB |
Time limit exceeded |
14 |
Execution timed out |
3076 ms |
2384 KB |
Time limit exceeded |
15 |
Execution timed out |
3060 ms |
2384 KB |
Time limit exceeded |
16 |
Execution timed out |
3064 ms |
2384 KB |
Time limit exceeded |
17 |
Execution timed out |
3061 ms |
2384 KB |
Time limit exceeded |
18 |
Execution timed out |
3073 ms |
2384 KB |
Time limit exceeded |
19 |
Execution timed out |
3058 ms |
2384 KB |
Time limit exceeded |
20 |
Execution timed out |
3045 ms |
2384 KB |
Time limit exceeded |
21 |
Execution timed out |
3070 ms |
2640 KB |
Time limit exceeded |
22 |
Execution timed out |
3046 ms |
2660 KB |
Time limit exceeded |
23 |
Execution timed out |
3055 ms |
2640 KB |
Time limit exceeded |
24 |
Execution timed out |
3071 ms |
2640 KB |
Time limit exceeded |
25 |
Execution timed out |
3062 ms |
2640 KB |
Time limit exceeded |
26 |
Execution timed out |
3049 ms |
2640 KB |
Time limit exceeded |
27 |
Execution timed out |
3066 ms |
2640 KB |
Time limit exceeded |
28 |
Execution timed out |
3038 ms |
2836 KB |
Time limit exceeded |
29 |
Execution timed out |
3065 ms |
2640 KB |
Time limit exceeded |
30 |
Execution timed out |
3063 ms |
2640 KB |
Time limit exceeded |
31 |
Execution timed out |
3058 ms |
2384 KB |
Time limit exceeded |
32 |
Execution timed out |
3078 ms |
2384 KB |
Time limit exceeded |