#include "gap.h"
//#include "grader.cpp"
#include <bits/stdc++.h>
#define ll long long
#define str string
#define ins insert
#define ld long double
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define lb lower_bound
#define ub upper_bound
//#define endl "\n"
#define fr first
#define sc second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define sz size()
#define vll vector<ll>
#define bc back()
#define arr array
#define pll vector<pair<ll,ll>>
using namespace std;
template <class _T>
bool chmin(_T &x, const _T &y){
bool f=0;
if (x>y){x=y;f=1;}
return f;
}
template <class _T>
bool chmax(_T &x, const _T &y){
bool f=0;
if (x<y){x=y;f=1;}
return f;
}
const ll inf=1e18+7;
const ll mod=1e9+7;
const ld eps=1e-9;
long long findGap(int t, int n){
ll i,j;
ll a,b,c,d,l,r;
a=1,b=inf;
MinMax(a,b,&c,&d);
vector <ll> v;
v.pb(c),v.pb(d);
r=d,l=c;
ll ans=0;
if(t==1){
for(i=1;i<(n+1)/2;i++){
a=c+1;
b=d-1;
MinMax(a,b,&c,&d);
v.pb(c);
v.pb(d);
}
}
else{
j=(d-c-1)%(n-1);
for(i=l+1;i<r;i+=(r-l-1)/(n-1)){
a=i;
if(j>0){
i++;
j--;
}
b=i+(r-l-1)/(n-1)-1;
MinMax(a,b,&c,&d);
if(c==-1) continue;
v.pb(c);
v.pb(d);
}
}
sort(v.begin(),v.end());
for(i=1;i<v.sz;i++){
ans=max(ans,v[i]-v[i-1]);
}
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:74:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
74 | for(i=1;i<v.sz;i++){
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
2392 KB |
Output is correct |
3 |
Correct |
0 ms |
2392 KB |
Output is correct |
4 |
Correct |
0 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2392 KB |
Output is correct |
6 |
Correct |
1 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 |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 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 |
8 ms |
2840 KB |
Output is correct |
17 |
Correct |
8 ms |
3092 KB |
Output is correct |
18 |
Correct |
8 ms |
2836 KB |
Output is correct |
19 |
Correct |
8 ms |
2836 KB |
Output is correct |
20 |
Correct |
7 ms |
2816 KB |
Output is correct |
21 |
Correct |
31 ms |
3996 KB |
Output is correct |
22 |
Correct |
31 ms |
3996 KB |
Output is correct |
23 |
Correct |
31 ms |
4016 KB |
Output is correct |
24 |
Correct |
31 ms |
3988 KB |
Output is correct |
25 |
Correct |
28 ms |
3992 KB |
Output is correct |
26 |
Correct |
37 ms |
3992 KB |
Output is correct |
27 |
Correct |
31 ms |
3992 KB |
Output is correct |
28 |
Correct |
31 ms |
4000 KB |
Output is correct |
29 |
Correct |
32 ms |
3992 KB |
Output is correct |
30 |
Correct |
26 ms |
3992 KB |
Output is correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Correct |
0 ms |
2392 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 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 |
1 ms |
2548 KB |
Output is correct |
7 |
Correct |
0 ms |
2392 KB |
Output is correct |
8 |
Correct |
1 ms |
2392 KB |
Output is correct |
9 |
Correct |
1 ms |
2392 KB |
Output is correct |
10 |
Correct |
1 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 |
10 ms |
2964 KB |
Output is correct |
17 |
Correct |
10 ms |
2960 KB |
Output is correct |
18 |
Correct |
10 ms |
2964 KB |
Output is correct |
19 |
Correct |
10 ms |
2964 KB |
Output is correct |
20 |
Correct |
5 ms |
2548 KB |
Output is correct |
21 |
Correct |
42 ms |
3984 KB |
Output is correct |
22 |
Correct |
40 ms |
3772 KB |
Output is correct |
23 |
Correct |
42 ms |
3996 KB |
Output is correct |
24 |
Correct |
40 ms |
4000 KB |
Output is correct |
25 |
Correct |
40 ms |
5020 KB |
Output is correct |
26 |
Correct |
45 ms |
3948 KB |
Output is correct |
27 |
Correct |
41 ms |
4000 KB |
Output is correct |
28 |
Correct |
41 ms |
3992 KB |
Output is correct |
29 |
Correct |
41 ms |
3996 KB |
Output is correct |
30 |
Correct |
22 ms |
3108 KB |
Output is correct |
31 |
Correct |
1 ms |
2392 KB |
Output is correct |
32 |
Correct |
1 ms |
2392 KB |
Output is correct |