# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
240545 |
2020-06-19T21:51:37 Z |
Dremix10 |
Gap (APIO16_gap) |
C++17 |
|
64 ms |
2424 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define F first
#define S second
#define endl '\n'
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define maxp 22
#define EPS (ld)(1e-18)
#define mod (int)(1e9+7)
//#define N (int)(1e5+1)
long long findGap(int T, int N){
if(T==1){
int i;
vector<ll> arr;
ll limit=(N+1)/2;
ll l=1,r=1e18+1;
while(arr.size()<N){
ll mini,maxi;
ll* p1 = &mini;
ll* p2 = &maxi;
MinMax(l,r,p1,p2);
arr.push_back(mini);
if(arr.size()<N)
arr.push_back(maxi);
l=mini+1;
r=maxi-1;
}
sort(arr.begin(),arr.end());
ll ans=0;
for(i=0;i<N-1;i++)
ans=max(ans,arr[i+1]-arr[i]);
return ans;
}
int i;
ll low,high;
MinMax(0,(ll)1e18,&low,&high);
ll range=high-low+1;
ll ans=range/N;
if(range%N)
ans++;
ll nxt=low+1;
ll prev=low;
while(nxt<=high){
ll mini,maxi;
MinMax(nxt,nxt+ans,&mini,&maxi);
nxt+=ans+1;
if(mini==-1){
// nxt+=ans+1;
continue;
}
ans=max(ans,mini-prev);
prev=maxi;
}
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:27:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(arr.size()<N){
~~~~~~~~~~^~
gap.cpp:33:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(arr.size()<N)
~~~~~~~~~~^~
gap.cpp:23:12: warning: unused variable 'limit' [-Wunused-variable]
ll limit=(N+1)/2;
^~~~~
gap.cpp:46:9: warning: unused variable 'i' [-Wunused-variable]
int i;
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
288 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
6 ms |
384 KB |
Output is correct |
16 |
Correct |
18 ms |
896 KB |
Output is correct |
17 |
Correct |
18 ms |
976 KB |
Output is correct |
18 |
Correct |
18 ms |
896 KB |
Output is correct |
19 |
Correct |
18 ms |
896 KB |
Output is correct |
20 |
Correct |
15 ms |
1152 KB |
Output is correct |
21 |
Correct |
59 ms |
2288 KB |
Output is correct |
22 |
Correct |
59 ms |
2288 KB |
Output is correct |
23 |
Correct |
61 ms |
2288 KB |
Output is correct |
24 |
Correct |
63 ms |
2292 KB |
Output is correct |
25 |
Correct |
51 ms |
2272 KB |
Output is correct |
26 |
Correct |
59 ms |
2312 KB |
Output is correct |
27 |
Correct |
58 ms |
2316 KB |
Output is correct |
28 |
Correct |
64 ms |
2276 KB |
Output is correct |
29 |
Correct |
58 ms |
2424 KB |
Output is correct |
30 |
Correct |
44 ms |
2264 KB |
Output is correct |
31 |
Correct |
5 ms |
384 KB |
Output is correct |
32 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
14 ms |
512 KB |
Output is correct |
17 |
Correct |
13 ms |
512 KB |
Output is correct |
18 |
Correct |
13 ms |
512 KB |
Output is correct |
19 |
Correct |
15 ms |
512 KB |
Output is correct |
20 |
Correct |
10 ms |
512 KB |
Output is correct |
21 |
Correct |
48 ms |
1132 KB |
Output is correct |
22 |
Correct |
39 ms |
1120 KB |
Output is correct |
23 |
Correct |
39 ms |
1104 KB |
Output is correct |
24 |
Correct |
47 ms |
1276 KB |
Output is correct |
25 |
Correct |
62 ms |
1152 KB |
Output is correct |
26 |
Correct |
48 ms |
1060 KB |
Output is correct |
27 |
Correct |
38 ms |
1144 KB |
Output is correct |
28 |
Correct |
39 ms |
1096 KB |
Output is correct |
29 |
Correct |
38 ms |
1148 KB |
Output is correct |
30 |
Correct |
28 ms |
1152 KB |
Output is correct |
31 |
Correct |
4 ms |
384 KB |
Output is correct |
32 |
Correct |
5 ms |
384 KB |
Output is correct |