# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
74724 |
2018-09-07T03:07:36 Z |
goodbaton |
Gap (APIO16_gap) |
C++14 |
|
80 ms |
18276 KB |
#include <cstdio>
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include "gap.h"
using namespace std;
typedef long long ll;
#define mod 1000000007
#define SIZE 10000
long long findGap1(int T, int N){
ll l = 0, r = 1e18;
vector<ll> vec;
while(1){
ll a, b;
MinMax(l,r,&a,&b);
if(a==-1) break;
vec.push_back(a);
if(a==b) break;
vec.push_back(b);
if(a+1==b) break;
if(vec.size() == N) break;
l = a+1;
r = b-1;
}
sort(vec.begin(),vec.end());
ll ans = 0;
for(int i=1;i<vec.size();i++)
ans = max(ans, vec[i] - vec[i-1]);
return ans;
}
long long findGap(int T, int N){
if(T==1) return findGap1(T,N);
ll MAX = 1e18;
ll l, r;
vector<ll> vec;
MinMax(0,(ll)1e18,&l,&r); //N
ll D = r-l+1 - N;
ll B = (D+(N-1))/N + 2;
vec.push_back(l);
vec.push_back(r);
for(ll s = l+1;s<r;s+=B){
ll a,b;
MinMax(s,s+B-1,&a,&b);
if(a!=-1 && a==b){
vec.push_back(a);
}else if(a!=-1){
vec.push_back(a);
vec.push_back(b);
}
}
sort(vec.begin(),vec.end());
ll ans = 0;
for(int i=1;i<vec.size();i++)
ans = max(ans, vec[i] - vec[i-1]);
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap1(int, int)':
gap.cpp:35:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(vec.size() == N) break;
~~~~~~~~~~~^~~~
gap.cpp:45:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=1;i<vec.size();i++)
~^~~~~~~~~~~
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:83:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=1;i<vec.size();i++)
~^~~~~~~~~~~
gap.cpp:55:6: warning: unused variable 'MAX' [-Wunused-variable]
ll MAX = 1e18;
^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
516 KB |
Output is correct |
3 |
Correct |
2 ms |
516 KB |
Output is correct |
4 |
Correct |
2 ms |
516 KB |
Output is correct |
5 |
Correct |
2 ms |
516 KB |
Output is correct |
6 |
Correct |
2 ms |
516 KB |
Output is correct |
7 |
Correct |
2 ms |
516 KB |
Output is correct |
8 |
Correct |
2 ms |
516 KB |
Output is correct |
9 |
Correct |
2 ms |
628 KB |
Output is correct |
10 |
Correct |
2 ms |
628 KB |
Output is correct |
11 |
Correct |
3 ms |
672 KB |
Output is correct |
12 |
Correct |
3 ms |
712 KB |
Output is correct |
13 |
Correct |
3 ms |
712 KB |
Output is correct |
14 |
Correct |
3 ms |
716 KB |
Output is correct |
15 |
Correct |
3 ms |
888 KB |
Output is correct |
16 |
Correct |
17 ms |
1816 KB |
Output is correct |
17 |
Correct |
16 ms |
2280 KB |
Output is correct |
18 |
Correct |
17 ms |
2744 KB |
Output is correct |
19 |
Correct |
17 ms |
3208 KB |
Output is correct |
20 |
Correct |
13 ms |
3360 KB |
Output is correct |
21 |
Correct |
64 ms |
6640 KB |
Output is correct |
22 |
Correct |
61 ms |
8348 KB |
Output is correct |
23 |
Correct |
63 ms |
10196 KB |
Output is correct |
24 |
Correct |
63 ms |
12040 KB |
Output is correct |
25 |
Correct |
54 ms |
13244 KB |
Output is correct |
26 |
Correct |
62 ms |
15096 KB |
Output is correct |
27 |
Correct |
64 ms |
16924 KB |
Output is correct |
28 |
Correct |
66 ms |
18148 KB |
Output is correct |
29 |
Correct |
66 ms |
18148 KB |
Output is correct |
30 |
Correct |
55 ms |
18148 KB |
Output is correct |
31 |
Correct |
2 ms |
18148 KB |
Output is correct |
32 |
Correct |
3 ms |
18148 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
18148 KB |
Output is correct |
2 |
Correct |
3 ms |
18148 KB |
Output is correct |
3 |
Correct |
2 ms |
18148 KB |
Output is correct |
4 |
Correct |
2 ms |
18148 KB |
Output is correct |
5 |
Correct |
2 ms |
18148 KB |
Output is correct |
6 |
Correct |
2 ms |
18148 KB |
Output is correct |
7 |
Correct |
2 ms |
18148 KB |
Output is correct |
8 |
Correct |
2 ms |
18148 KB |
Output is correct |
9 |
Correct |
2 ms |
18148 KB |
Output is correct |
10 |
Correct |
2 ms |
18148 KB |
Output is correct |
11 |
Correct |
3 ms |
18148 KB |
Output is correct |
12 |
Correct |
3 ms |
18148 KB |
Output is correct |
13 |
Correct |
3 ms |
18148 KB |
Output is correct |
14 |
Correct |
3 ms |
18148 KB |
Output is correct |
15 |
Correct |
3 ms |
18148 KB |
Output is correct |
16 |
Correct |
20 ms |
18148 KB |
Output is correct |
17 |
Correct |
20 ms |
18148 KB |
Output is correct |
18 |
Correct |
19 ms |
18148 KB |
Output is correct |
19 |
Correct |
20 ms |
18148 KB |
Output is correct |
20 |
Correct |
10 ms |
18148 KB |
Output is correct |
21 |
Correct |
79 ms |
18152 KB |
Output is correct |
22 |
Correct |
80 ms |
18152 KB |
Output is correct |
23 |
Correct |
78 ms |
18152 KB |
Output is correct |
24 |
Correct |
74 ms |
18152 KB |
Output is correct |
25 |
Correct |
71 ms |
18152 KB |
Output is correct |
26 |
Correct |
78 ms |
18276 KB |
Output is correct |
27 |
Correct |
76 ms |
18276 KB |
Output is correct |
28 |
Correct |
76 ms |
18276 KB |
Output is correct |
29 |
Correct |
75 ms |
18276 KB |
Output is correct |
30 |
Correct |
53 ms |
18276 KB |
Output is correct |
31 |
Correct |
2 ms |
18276 KB |
Output is correct |
32 |
Correct |
2 ms |
18276 KB |
Output is correct |