# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
338886 |
2020-12-24T06:25:29 Z |
Kerim |
Gap (APIO16_gap) |
C++17 |
|
62 ms |
3356 KB |
#include "gap.h"
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x) cerr<< #x <<" = "<< x<<endl;
using namespace std;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
typedef long long ll;
const ll B=1e18;
long long findGap(int T, int N){
if(T==1){
vector<ll>ans(N);
MinMax(0LL,B,&ans[0],&ans[N-1]);
for(int l=1,r=N-2;l<=r;l++,r--)
MinMax(ans[l-1]+1,ans[r+1]-1,&ans[l],&ans[r]);
ll res=-1;
for(int i=0;i<N-1;i++)
umax(res,ans[i+1]-ans[i]);
return res;
}
ll a,b,mn,mx;
MinMax(0LL,B,&mn,&mx);
ll d=(mx-mn-1)/(N-1);
vector<ll>ans;ans.pb(mn);
for(ll l=mn+1;l<mx;l+=d+1){
MinMax(l,min(l+d,mx-1),&a,&b);
if(~a)
ans.pb(a),ans.pb(b);
}ans.pb(mx);
ll res=-1;
for(int i=0;i<int(ans.size())-1;i++)
umax(res,ans[i+1]-ans[i]);
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
0 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
492 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
11 ms |
748 KB |
Output is correct |
17 |
Correct |
11 ms |
748 KB |
Output is correct |
18 |
Correct |
11 ms |
748 KB |
Output is correct |
19 |
Correct |
11 ms |
748 KB |
Output is correct |
20 |
Correct |
9 ms |
748 KB |
Output is correct |
21 |
Correct |
42 ms |
1980 KB |
Output is correct |
22 |
Correct |
48 ms |
1900 KB |
Output is correct |
23 |
Correct |
43 ms |
1852 KB |
Output is correct |
24 |
Correct |
43 ms |
1900 KB |
Output is correct |
25 |
Correct |
41 ms |
1900 KB |
Output is correct |
26 |
Correct |
47 ms |
1900 KB |
Output is correct |
27 |
Correct |
43 ms |
2028 KB |
Output is correct |
28 |
Correct |
42 ms |
1900 KB |
Output is correct |
29 |
Correct |
45 ms |
1900 KB |
Output is correct |
30 |
Correct |
34 ms |
1900 KB |
Output is correct |
31 |
Correct |
0 ms |
364 KB |
Output is correct |
32 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
1 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
17 ms |
876 KB |
Output is correct |
17 |
Correct |
15 ms |
876 KB |
Output is correct |
18 |
Correct |
15 ms |
876 KB |
Output is correct |
19 |
Correct |
15 ms |
876 KB |
Output is correct |
20 |
Correct |
7 ms |
492 KB |
Output is correct |
21 |
Correct |
60 ms |
2276 KB |
Output is correct |
22 |
Correct |
60 ms |
2276 KB |
Output is correct |
23 |
Correct |
59 ms |
2252 KB |
Output is correct |
24 |
Correct |
61 ms |
2276 KB |
Output is correct |
25 |
Correct |
58 ms |
3356 KB |
Output is correct |
26 |
Correct |
62 ms |
2300 KB |
Output is correct |
27 |
Correct |
60 ms |
2532 KB |
Output is correct |
28 |
Correct |
60 ms |
2332 KB |
Output is correct |
29 |
Correct |
60 ms |
2276 KB |
Output is correct |
30 |
Correct |
32 ms |
1528 KB |
Output is correct |
31 |
Correct |
0 ms |
364 KB |
Output is correct |
32 |
Correct |
1 ms |
364 KB |
Output is correct |