# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
718246 |
2023-04-03T17:50:21 Z |
Urvuk3 |
Gap (APIO16_gap) |
C++17 |
|
59 ms |
3260 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int INF=1e9;
const ll LINF=1e18;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define mid ((l+r)/2)
#define sz(a) (int((a).size()))
#define all(a) a.begin(),a.end()
#define endl "\n"
#define pb push_back
void PRINT(int x) {cerr << x;}
void PRINT(ll x) {cerr << x;}
void PRINT(double x) {cerr << x;}
void PRINT(char x) {cerr << '\'' << x << '\'';}
void PRINT(string x) {cerr << '\"' << x << '\"';}
void PRINT(bool x) {cerr << (x ? "true" : "false");}
template<typename T,typename V>
void PRINT(pair<T,V>& x){
cerr<<"{";
PRINT(x.fi);
cerr<<",";
PRINT(x.se);
cerr<<"}";
}
template<typename T>
void PRINT(T &x){
int id=0;
cerr<<"{";
for(auto _i:x){
cerr<<(id++ ? "," : "");
PRINT(_i);
}
cerr<<"}";
}
void _PRINT(){
cerr<<"]\n";
}
template<typename Head,typename... Tail>
void _PRINT(Head h,Tail... t){
PRINT(h);
if(sizeof...(t)) cerr<<", ";
_PRINT(t...);
}
#define Debug(x...) cerr<<"["<<#x<<"]=["; _PRINT(x)
long long findGap(int T, int N){
if(T==1){
ll l=0,r=LINF;
vector<ll> a;
for(int i=1;i<=(N+1)/2;i++){
ll mn,mx;
MinMax(l,r,&mn,&mx);
a.pb(mn); a.pb(mx);
l=mn+1,r=mx-1;
}
sort(all(a));
ll res=0;
for(int i=0;i<sz(a)-1;i++){
res=max(res,a[i+1]-a[i]);
}
return res;
}
else{
vector<ll> a;
ll mn,mx;
MinMax(0,LINF,&mn,&mx);
ll l=mn,r=mx;
a.pb(l); a.pb(r);
l++,r--;
if(N!=2){
ll seg_sz=(r-l+1)/(N-2);
ll cnt=(r-l+1)%(N-2);
vector<pll> segs;
ll l1,r1=l-1;
for(int i=1;i<=N-2;i++){
l1=r1+1;
if(cnt){
r1=l1+seg_sz;
cnt--;
}
else r1=l1+seg_sz-1;
ll mn,mx;
MinMax(l1,r1,&mn,&mx);
if(mn!=-1){
a.pb(mn); a.pb(mx);
}
}
}
ll res=0;
sort(all(a));
for(int i=0;i<sz(a)-1;i++){
res=max(res,a[i+1]-a[i]);
}
return res;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
1 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
10 ms |
912 KB |
Output is correct |
17 |
Correct |
10 ms |
848 KB |
Output is correct |
18 |
Correct |
11 ms |
864 KB |
Output is correct |
19 |
Correct |
11 ms |
848 KB |
Output is correct |
20 |
Correct |
8 ms |
848 KB |
Output is correct |
21 |
Correct |
41 ms |
2176 KB |
Output is correct |
22 |
Correct |
38 ms |
2208 KB |
Output is correct |
23 |
Correct |
45 ms |
2148 KB |
Output is correct |
24 |
Correct |
38 ms |
2200 KB |
Output is correct |
25 |
Correct |
34 ms |
2200 KB |
Output is correct |
26 |
Correct |
42 ms |
2200 KB |
Output is correct |
27 |
Correct |
38 ms |
2188 KB |
Output is correct |
28 |
Correct |
41 ms |
2220 KB |
Output is correct |
29 |
Correct |
44 ms |
2188 KB |
Output is correct |
30 |
Correct |
33 ms |
2212 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
220 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
12 ms |
892 KB |
Output is correct |
17 |
Correct |
12 ms |
812 KB |
Output is correct |
18 |
Correct |
14 ms |
896 KB |
Output is correct |
19 |
Correct |
12 ms |
852 KB |
Output is correct |
20 |
Correct |
6 ms |
464 KB |
Output is correct |
21 |
Correct |
58 ms |
2240 KB |
Output is correct |
22 |
Correct |
59 ms |
2216 KB |
Output is correct |
23 |
Correct |
51 ms |
2140 KB |
Output is correct |
24 |
Correct |
50 ms |
2204 KB |
Output is correct |
25 |
Correct |
51 ms |
3260 KB |
Output is correct |
26 |
Correct |
50 ms |
2192 KB |
Output is correct |
27 |
Correct |
56 ms |
2256 KB |
Output is correct |
28 |
Correct |
49 ms |
2200 KB |
Output is correct |
29 |
Correct |
49 ms |
2208 KB |
Output is correct |
30 |
Correct |
26 ms |
1460 KB |
Output is correct |
31 |
Correct |
1 ms |
208 KB |
Output is correct |
32 |
Correct |
1 ms |
208 KB |
Output is correct |