# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1005933 |
2024-06-23T08:12:50 Z |
vjudge1 |
Gap (APIO16_gap) |
C++17 |
|
134 ms |
3588 KB |
#include<bits/stdc++.h>
#include "gap.h"
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#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 vl vector<ll>
using namespace std;
const int mxn=3e5+5;
/*multiset<ll>ms;
void MinMax(ll x,ll y,ll &x1,ll &y1){
x1=*ms.lower_bound(x);
y1=*prev(ms.upper_bound(y));
}*/
ll sol1(int n){
ll mn=0,mx=1e18;
int l=1,r=n;
ll a[n+1];
while(l<=r){
ll s,t;
MinMax(mn,mx,&s,&t);
a[l++]=s;a[r--]=t;
mn=s+1,mx=t-1;
}ll ans=0;
for(int i=2;i<=n;i++)ans=max(ans,a[i]-a[i-1]);
return ans;
}
ll sol2(int n){
ll mn=0,mx=1e18;
ll s,t;MinMax(mn,mx,&s,&t);
ll add = (t-s-1)/(n-1)+1;
ll ans=add;
while(s<t){
ll cmn=s,cmx=s;
ll tt=2;
while(1){
ll cl=cmn,cr=cmx;
MinMax(s+(tt-1)*add,s+tt*add,&cl,&cr);
if(cl==-1&&cr==-1){tt++;continue;}
cmn=cl,cmx=cr;break;
}
if(cmn==cmx)cmn=s;
ans=max(ans,cmx-cmn);
s=cmx;
}return ans;
}
long long findGap(int T, int N){
if(T==1)return sol1(N);
else return sol2(N);
}
/*int main(){
int n;cin>>n;
for(int i=1;i<=n;i++){
int x;cin>>x;ms.insert(x);
}for(auto it : ms)cout<<it<<' ';cout<<'\n';
cout<<findGap(2,n);
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 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 |
0 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 |
0 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 |
6 ms |
2648 KB |
Output is correct |
17 |
Correct |
6 ms |
2648 KB |
Output is correct |
18 |
Correct |
7 ms |
2648 KB |
Output is correct |
19 |
Correct |
6 ms |
2648 KB |
Output is correct |
20 |
Correct |
6 ms |
2648 KB |
Output is correct |
21 |
Correct |
26 ms |
3588 KB |
Output is correct |
22 |
Correct |
30 ms |
3456 KB |
Output is correct |
23 |
Correct |
25 ms |
3412 KB |
Output is correct |
24 |
Correct |
26 ms |
3416 KB |
Output is correct |
25 |
Correct |
23 ms |
3416 KB |
Output is correct |
26 |
Correct |
26 ms |
3416 KB |
Output is correct |
27 |
Correct |
25 ms |
3416 KB |
Output is correct |
28 |
Correct |
25 ms |
3416 KB |
Output is correct |
29 |
Correct |
30 ms |
3416 KB |
Output is correct |
30 |
Correct |
20 ms |
3416 KB |
Output is correct |
31 |
Correct |
0 ms |
2392 KB |
Output is correct |
32 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Incorrect |
0 ms |
2392 KB |
Output isn't correct |
3 |
Incorrect |
0 ms |
2392 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
2392 KB |
Output isn't correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Runtime error |
0 ms |
2392 KB |
Execution failed because the return code was nonzero |
7 |
Correct |
0 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 |
Incorrect |
0 ms |
2392 KB |
Output isn't correct |
11 |
Correct |
1 ms |
2392 KB |
Output is correct |
12 |
Runtime error |
1 ms |
2392 KB |
Execution failed because the return code was nonzero |
13 |
Runtime error |
2 ms |
2392 KB |
Execution failed because the return code was nonzero |
14 |
Incorrect |
0 ms |
2392 KB |
Output isn't correct |
15 |
Correct |
1 ms |
2392 KB |
Output is correct |
16 |
Correct |
7 ms |
2392 KB |
Output is correct |
17 |
Correct |
6 ms |
2592 KB |
Output is correct |
18 |
Correct |
6 ms |
2392 KB |
Output is correct |
19 |
Incorrect |
7 ms |
2392 KB |
Output isn't correct |
20 |
Incorrect |
5 ms |
2388 KB |
Output isn't correct |
21 |
Runtime error |
128 ms |
2844 KB |
Execution failed because the return code was nonzero |
22 |
Runtime error |
134 ms |
2648 KB |
Execution failed because the return code was nonzero |
23 |
Incorrect |
30 ms |
2648 KB |
Output isn't correct |
24 |
Correct |
26 ms |
2648 KB |
Output is correct |
25 |
Correct |
21 ms |
2648 KB |
Output is correct |
26 |
Correct |
29 ms |
2792 KB |
Output is correct |
27 |
Incorrect |
34 ms |
2648 KB |
Output isn't correct |
28 |
Runtime error |
123 ms |
2648 KB |
Execution failed because the return code was nonzero |
29 |
Incorrect |
35 ms |
2688 KB |
Output isn't correct |
30 |
Incorrect |
18 ms |
2868 KB |
Output isn't correct |
31 |
Correct |
0 ms |
2392 KB |
Output is correct |
32 |
Correct |
0 ms |
2392 KB |
Output is correct |