# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
200825 |
2020-02-08T09:15:51 Z |
Rakhmand |
Gap (APIO16_gap) |
C++14 |
|
79 ms |
3308 KB |
#include "gap.h"
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
using namespace std;
typedef long long llong;
long long a[100010];
long long ans;
set<llong> st;
llong n;
void get(llong l, llong r){
if(ans >= r - l){
return ;
}
llong sz = (r - l + n - 1) / n;
llong last = l;
vector<pair<llong, llong> > vec;
for(llong tl = l; tl < r; tl += sz + 1){
llong tr = min(tl + sz, r - 1);
llong mn = NULL, mx = NULL;
MinMax(tl, tr, &mn, &mx);
if(mn == -1){
continue;
}
ans = max(ans, mn - last);
vec.push_back({mn, mx});
last = mx;
}
ans = max(r - last, ans);
for(int i = 0; i < vec.size(); i++){
get(vec[i].first, vec[i].second);
}
}
long long findGap(int T, int N) {
n = N;
if(T == 1){
int L = 1, R = N;
long long l = 0, r = 1e18;
while(R >= L){
long long mn = NULL, mx = NULL;
MinMax(l, r, &mn, &mx);
a[L++] = mn;
a[R--] = mx;
l = mn + 1;
r = mx - 1;
}
for(int i = 1; i < N; i++){
if(a[i + 1] - a[i] > ans){
ans = a[i + 1] - a[i];
}
}
return ans;
}else{
llong mn = NULL, mx = NULL;
MinMax(1, (llong) 1e18, &mn, &mx);
get(mn, mx);
return ans;
}
return 0;
}
Compilation message
gap.cpp: In function 'void get(llong, llong)':
gap.cpp:43:20: warning: converting to non-pointer type 'llong {aka long long int}' from NULL [-Wconversion-null]
llong mn = NULL, mx = NULL;
^~~~
gap.cpp:43:31: warning: converting to non-pointer type 'llong {aka long long int}' from NULL [-Wconversion-null]
llong mn = NULL, mx = NULL;
^~~~
gap.cpp:53:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < vec.size(); i++){
~~^~~~~~~~~~~~
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:64:28: warning: converting to non-pointer type 'long long int' from NULL [-Wconversion-null]
long long mn = NULL, mx = NULL;
^~~~
gap.cpp:64:39: warning: converting to non-pointer type 'long long int' from NULL [-Wconversion-null]
long long mn = NULL, mx = NULL;
^~~~
gap.cpp:78:20: warning: converting to non-pointer type 'llong {aka long long int}' from NULL [-Wconversion-null]
llong mn = NULL, mx = NULL;
^~~~
gap.cpp:78:31: warning: converting to non-pointer type 'llong {aka long long int}' from NULL [-Wconversion-null]
llong mn = NULL, mx = NULL;
^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
248 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
4 ms |
248 KB |
Output is correct |
4 |
Correct |
5 ms |
248 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
5 ms |
248 KB |
Output is correct |
7 |
Correct |
5 ms |
252 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
5 ms |
248 KB |
Output is correct |
13 |
Correct |
5 ms |
248 KB |
Output is correct |
14 |
Correct |
5 ms |
248 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
17 ms |
636 KB |
Output is correct |
17 |
Correct |
18 ms |
632 KB |
Output is correct |
18 |
Correct |
21 ms |
632 KB |
Output is correct |
19 |
Correct |
17 ms |
616 KB |
Output is correct |
20 |
Correct |
14 ms |
632 KB |
Output is correct |
21 |
Correct |
64 ms |
1836 KB |
Output is correct |
22 |
Correct |
60 ms |
1912 KB |
Output is correct |
23 |
Correct |
58 ms |
1860 KB |
Output is correct |
24 |
Correct |
55 ms |
1912 KB |
Output is correct |
25 |
Correct |
56 ms |
1792 KB |
Output is correct |
26 |
Correct |
58 ms |
1928 KB |
Output is correct |
27 |
Correct |
55 ms |
1784 KB |
Output is correct |
28 |
Correct |
55 ms |
1912 KB |
Output is correct |
29 |
Correct |
62 ms |
1876 KB |
Output is correct |
30 |
Correct |
40 ms |
1860 KB |
Output is correct |
31 |
Correct |
4 ms |
248 KB |
Output is correct |
32 |
Correct |
4 ms |
248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
248 KB |
Output is correct |
2 |
Correct |
5 ms |
248 KB |
Output is correct |
3 |
Correct |
5 ms |
248 KB |
Output is correct |
4 |
Correct |
5 ms |
248 KB |
Output is correct |
5 |
Correct |
4 ms |
248 KB |
Output is correct |
6 |
Correct |
5 ms |
248 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
248 KB |
Output is correct |
9 |
Correct |
5 ms |
248 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
5 ms |
376 KB |
Output is correct |
12 |
Correct |
6 ms |
376 KB |
Output is correct |
13 |
Correct |
6 ms |
376 KB |
Output is correct |
14 |
Correct |
6 ms |
380 KB |
Output is correct |
15 |
Correct |
5 ms |
376 KB |
Output is correct |
16 |
Correct |
21 ms |
888 KB |
Output is correct |
17 |
Correct |
22 ms |
888 KB |
Output is correct |
18 |
Correct |
20 ms |
888 KB |
Output is correct |
19 |
Correct |
21 ms |
892 KB |
Output is correct |
20 |
Correct |
12 ms |
504 KB |
Output is correct |
21 |
Correct |
72 ms |
2260 KB |
Output is correct |
22 |
Correct |
78 ms |
2448 KB |
Output is correct |
23 |
Correct |
79 ms |
2324 KB |
Output is correct |
24 |
Correct |
71 ms |
2288 KB |
Output is correct |
25 |
Correct |
64 ms |
3308 KB |
Output is correct |
26 |
Correct |
72 ms |
2332 KB |
Output is correct |
27 |
Correct |
74 ms |
2232 KB |
Output is correct |
28 |
Correct |
73 ms |
2284 KB |
Output is correct |
29 |
Correct |
71 ms |
2288 KB |
Output is correct |
30 |
Correct |
49 ms |
1536 KB |
Output is correct |
31 |
Correct |
5 ms |
248 KB |
Output is correct |
32 |
Correct |
6 ms |
376 KB |
Output is correct |