# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
274827 |
2020-08-19T16:23:57 Z |
test2 |
Gap (APIO16_gap) |
C++14 |
|
81 ms |
3308 KB |
#include <bits/stdc++.h>
#include <stdlib.h>
#include "gap.h"
#define I inline void
using ll = long long ;
using ld = long double ;
using namespace std ;
const int mod = 1e9 + 7 ;
long long findGap(int T, int N)
{
ll ans = 0 ;
if(T == 1){
ll lo = 0, hi = 1e18 ;
multiset<ll> s ;
int l = 0 , r = N - 1;
vector<ll> arr(N+1 , 0) ;
while(l<=r){
ll mn ,mx ;
MinMax(lo , hi , &mn , &mx) ;
arr[l] = mn ;
arr[r] = mx ;
l++ ;
r-- ;
lo = mn + 1 ;
hi = mx - 1;
}
for(int i =1 ;i < N ;i++)
ans = max(ans , arr[i] - arr[i-1]) ;
}
else{
ll mn , mx ;
MinMax(0 , 1e18 , &mn , &mx) ;
ll d = (mx - mn - 1 + N - 2 ) / (N - 1) ;
vector<ll> vec = {mn , mx } ;
ll cur = mn + 1 ;
while(cur < vec[1]){
MinMax(cur , min(vec[1] - 1, cur + d - 1 ) , &mn , &mx) ;
cur+=d ;
if(mn == -1){
continue ;
}
vec.push_back(mn) ;
vec.push_back(mx) ;
if(ans > vec[1] - vec.back())break ;
}
sort(vec.begin() , vec.end()) ;
for(int i = 1 ; i < (int) vec.size() ;i ++){
ans = max(ans , vec[i] - vec[i-1] ) ;
}
}
return ans ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
16 ms |
768 KB |
Output is correct |
17 |
Correct |
14 ms |
768 KB |
Output is correct |
18 |
Correct |
13 ms |
768 KB |
Output is correct |
19 |
Correct |
15 ms |
760 KB |
Output is correct |
20 |
Correct |
9 ms |
768 KB |
Output is correct |
21 |
Correct |
57 ms |
1912 KB |
Output is correct |
22 |
Correct |
54 ms |
1940 KB |
Output is correct |
23 |
Correct |
52 ms |
1884 KB |
Output is correct |
24 |
Correct |
52 ms |
1908 KB |
Output is correct |
25 |
Correct |
43 ms |
1912 KB |
Output is correct |
26 |
Correct |
56 ms |
1960 KB |
Output is correct |
27 |
Correct |
55 ms |
1880 KB |
Output is correct |
28 |
Correct |
53 ms |
1928 KB |
Output is correct |
29 |
Correct |
55 ms |
1880 KB |
Output is correct |
30 |
Correct |
38 ms |
1920 KB |
Output is correct |
31 |
Correct |
1 ms |
384 KB |
Output is correct |
32 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
17 ms |
896 KB |
Output is correct |
17 |
Correct |
19 ms |
928 KB |
Output is correct |
18 |
Correct |
18 ms |
896 KB |
Output is correct |
19 |
Correct |
20 ms |
896 KB |
Output is correct |
20 |
Correct |
8 ms |
512 KB |
Output is correct |
21 |
Correct |
74 ms |
2328 KB |
Output is correct |
22 |
Correct |
74 ms |
2288 KB |
Output is correct |
23 |
Correct |
72 ms |
2316 KB |
Output is correct |
24 |
Correct |
78 ms |
2292 KB |
Output is correct |
25 |
Correct |
66 ms |
3308 KB |
Output is correct |
26 |
Correct |
77 ms |
2336 KB |
Output is correct |
27 |
Correct |
73 ms |
2328 KB |
Output is correct |
28 |
Correct |
81 ms |
2224 KB |
Output is correct |
29 |
Correct |
71 ms |
2288 KB |
Output is correct |
30 |
Correct |
34 ms |
1528 KB |
Output is correct |
31 |
Correct |
0 ms |
384 KB |
Output is correct |
32 |
Correct |
0 ms |
384 KB |
Output is correct |