# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
107329 |
2019-04-23T10:56:28 Z |
maruii |
Gap (APIO16_gap) |
C++14 |
|
127 ms |
3312 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
long long findGap(int T, int N){
long long mn, mx, s=0, e=1e18, ans = 0;
if(T==1){
int i=0, j=N-1;
vector<long long> vec(N);
while(i<=j){
MinMax(s, e, &mn, &mx);
vec[i++] = mn, vec[j--] = mx;
s = mn+1, e = mx-1;
}
for(int i=1; i<N; ++i) ans = max(ans, abs(vec[i]-vec[i-1]));
return ans;
}
MinMax(0, 1e18, &mn, &mx);
s = mn, e = mx;
if(N==2) return e-s;
long long d = (e-s)/(N-1)+1;
vector<pair<long long, long long> > vec;
bool flag = 1;
for(int i=1; i<N; ++i){
MinMax(s+(i-1)*d, s+i*d-1, &mn, &mx);
if(mn != -1) vec.emplace_back(mn, mx);
else flag = 0;
}
if(flag) return d;
for(int i=1; i<vec.size(); ++i) ans = max(ans, vec[i].first - vec[i-1].second);
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:30:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=1; i<vec.size(); ++i) ans = max(ans, vec[i].first - vec[i-1].second);
~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
3 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Correct |
2 ms |
384 KB |
Output is correct |
16 |
Correct |
16 ms |
768 KB |
Output is correct |
17 |
Correct |
13 ms |
768 KB |
Output is correct |
18 |
Correct |
16 ms |
768 KB |
Output is correct |
19 |
Correct |
13 ms |
768 KB |
Output is correct |
20 |
Correct |
13 ms |
768 KB |
Output is correct |
21 |
Correct |
46 ms |
1916 KB |
Output is correct |
22 |
Correct |
46 ms |
1920 KB |
Output is correct |
23 |
Correct |
54 ms |
1920 KB |
Output is correct |
24 |
Correct |
47 ms |
1920 KB |
Output is correct |
25 |
Correct |
43 ms |
1920 KB |
Output is correct |
26 |
Correct |
51 ms |
1912 KB |
Output is correct |
27 |
Correct |
57 ms |
1920 KB |
Output is correct |
28 |
Correct |
53 ms |
1912 KB |
Output is correct |
29 |
Correct |
52 ms |
1920 KB |
Output is correct |
30 |
Correct |
40 ms |
1920 KB |
Output is correct |
31 |
Correct |
3 ms |
384 KB |
Output is correct |
32 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Incorrect |
2 ms |
256 KB |
Output isn't correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
3 ms |
384 KB |
Output is correct |
10 |
Correct |
3 ms |
384 KB |
Output is correct |
11 |
Correct |
3 ms |
384 KB |
Output is correct |
12 |
Correct |
3 ms |
384 KB |
Output is correct |
13 |
Correct |
3 ms |
384 KB |
Output is correct |
14 |
Correct |
3 ms |
384 KB |
Output is correct |
15 |
Incorrect |
3 ms |
384 KB |
Output isn't correct |
16 |
Correct |
17 ms |
896 KB |
Output is correct |
17 |
Correct |
18 ms |
896 KB |
Output is correct |
18 |
Correct |
19 ms |
888 KB |
Output is correct |
19 |
Correct |
19 ms |
1024 KB |
Output is correct |
20 |
Correct |
8 ms |
512 KB |
Output is correct |
21 |
Correct |
74 ms |
2260 KB |
Output is correct |
22 |
Correct |
84 ms |
2288 KB |
Output is correct |
23 |
Correct |
81 ms |
2416 KB |
Output is correct |
24 |
Correct |
80 ms |
2288 KB |
Output is correct |
25 |
Incorrect |
70 ms |
3312 KB |
Output isn't correct |
26 |
Correct |
75 ms |
2448 KB |
Output is correct |
27 |
Correct |
68 ms |
2288 KB |
Output is correct |
28 |
Correct |
76 ms |
2416 KB |
Output is correct |
29 |
Correct |
127 ms |
2288 KB |
Output is correct |
30 |
Correct |
38 ms |
1528 KB |
Output is correct |
31 |
Correct |
3 ms |
384 KB |
Output is correct |
32 |
Correct |
2 ms |
384 KB |
Output is correct |