#include "gap.h"
#include<bits/stdc++.h>
#define lf double
#define ll long long
#define cc pair<char,char>
#define ull unsigned ll
#define ii pair<int,int>
#define li pair<ll,int>
#define iii pair<int,ii>
#define iiii pair<ii,ii>
#define iiii2 pair<int,iii>
#define lii pair<ll,ii>
#define lolo pair<ll,ll>
#define heap priority_queue
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define all(x) x.begin(),x.end()
#define len(x) strlen(x)
#define sz(x) (int) x.size()
#define orta ((bas+son)/2)
#define min3(x,y,z) min(min(x,y),z)
#define max3(x,y,z) max(max(x,y),z)
#define umin(x,y) x=min(x,y)
#define umax(x,y) x=max(x,y)
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define MOD 998244353
#define inf 1000000000000000000ll
#define M 10000002
#define LOG 40
#define magic 100
#define KOK 250
#define EPS 0.0025
#define pw(x) ((1ll)<<(x))
#define PI 3.1415926535
using namespace std;
long long findGap(int T, int N) {
ll ans=0;
ll bas,son,a1=0,a2=inf;
vector<ll> possible;
if(T==2) {
MinMax(0,inf,&bas,&son);
ll ratio=(son-bas-1)/(N-1)+((son-bas-1)%(N-1)>0);
possible.pb(bas);
for(int i=1;i<N;i++) {
ll v1,v2;
MinMax(bas+ratio*(i-1)+1,bas+ratio*i,&v1,&v2);
if(v1!=-1) {
if(v1!=v2 || (sz(possible) && possible.back()!=v1)) possible.pb(v1);
possible.pb(v2);
}
}
if(possible.back()!=son) possible.pb(son);
}
else {
while(a1<=a2 && sz(possible)<N) {
MinMax(a1,a2,&bas,&son);
if(bas==-1) break ;
possible.pb(bas);
if(bas!=son) possible.pb(son);
a1=bas+1;
a2=son-1;
}
sort(all(possible));
}
for(int i=0;i<sz(possible)-1;i++) {
umax(ans,possible[i+1]-possible[i]);
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
428 KB |
Output is correct |
4 |
Correct |
2 ms |
504 KB |
Output is correct |
5 |
Correct |
2 ms |
580 KB |
Output is correct |
6 |
Correct |
2 ms |
580 KB |
Output is correct |
7 |
Correct |
2 ms |
620 KB |
Output is correct |
8 |
Correct |
2 ms |
636 KB |
Output is correct |
9 |
Correct |
2 ms |
636 KB |
Output is correct |
10 |
Correct |
2 ms |
636 KB |
Output is correct |
11 |
Correct |
7 ms |
636 KB |
Output is correct |
12 |
Correct |
4 ms |
636 KB |
Output is correct |
13 |
Correct |
3 ms |
648 KB |
Output is correct |
14 |
Correct |
3 ms |
648 KB |
Output is correct |
15 |
Correct |
4 ms |
648 KB |
Output is correct |
16 |
Correct |
16 ms |
1148 KB |
Output is correct |
17 |
Correct |
22 ms |
1212 KB |
Output is correct |
18 |
Correct |
19 ms |
1212 KB |
Output is correct |
19 |
Correct |
17 ms |
1212 KB |
Output is correct |
20 |
Correct |
13 ms |
1236 KB |
Output is correct |
21 |
Correct |
67 ms |
2608 KB |
Output is correct |
22 |
Correct |
64 ms |
2608 KB |
Output is correct |
23 |
Correct |
62 ms |
2608 KB |
Output is correct |
24 |
Correct |
63 ms |
2608 KB |
Output is correct |
25 |
Correct |
54 ms |
2608 KB |
Output is correct |
26 |
Correct |
83 ms |
2608 KB |
Output is correct |
27 |
Correct |
79 ms |
2608 KB |
Output is correct |
28 |
Correct |
63 ms |
2608 KB |
Output is correct |
29 |
Correct |
91 ms |
2608 KB |
Output is correct |
30 |
Correct |
51 ms |
2608 KB |
Output is correct |
31 |
Correct |
4 ms |
2608 KB |
Output is correct |
32 |
Correct |
2 ms |
2608 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
2608 KB |
Output is correct |
2 |
Correct |
3 ms |
2608 KB |
Output is correct |
3 |
Correct |
2 ms |
2608 KB |
Output is correct |
4 |
Correct |
3 ms |
2608 KB |
Output is correct |
5 |
Correct |
3 ms |
2608 KB |
Output is correct |
6 |
Correct |
2 ms |
2608 KB |
Output is correct |
7 |
Correct |
2 ms |
2608 KB |
Output is correct |
8 |
Correct |
2 ms |
2608 KB |
Output is correct |
9 |
Correct |
3 ms |
2608 KB |
Output is correct |
10 |
Correct |
3 ms |
2608 KB |
Output is correct |
11 |
Correct |
4 ms |
2608 KB |
Output is correct |
12 |
Correct |
4 ms |
2608 KB |
Output is correct |
13 |
Correct |
4 ms |
2608 KB |
Output is correct |
14 |
Correct |
3 ms |
2608 KB |
Output is correct |
15 |
Correct |
4 ms |
2608 KB |
Output is correct |
16 |
Correct |
20 ms |
2608 KB |
Output is correct |
17 |
Correct |
21 ms |
2608 KB |
Output is correct |
18 |
Correct |
21 ms |
2608 KB |
Output is correct |
19 |
Correct |
21 ms |
2608 KB |
Output is correct |
20 |
Correct |
13 ms |
2608 KB |
Output is correct |
21 |
Correct |
78 ms |
2608 KB |
Output is correct |
22 |
Correct |
88 ms |
2608 KB |
Output is correct |
23 |
Correct |
91 ms |
2676 KB |
Output is correct |
24 |
Correct |
87 ms |
2676 KB |
Output is correct |
25 |
Correct |
86 ms |
3508 KB |
Output is correct |
26 |
Correct |
86 ms |
3508 KB |
Output is correct |
27 |
Correct |
85 ms |
3508 KB |
Output is correct |
28 |
Correct |
98 ms |
3508 KB |
Output is correct |
29 |
Correct |
92 ms |
3508 KB |
Output is correct |
30 |
Correct |
44 ms |
3508 KB |
Output is correct |
31 |
Correct |
2 ms |
3508 KB |
Output is correct |
32 |
Correct |
2 ms |
3508 KB |
Output is correct |