# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
349292 |
2021-01-17T10:47:17 Z |
denkendoemeer |
Gap (APIO16_gap) |
C++14 |
|
69 ms |
3296 KB |
#include "gap.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
vector<ll>v;
ll findGap(int t,int n)
{
ll mini=0,maxi=1e18,i;
if (t==1){
for(i=0;i<(n+1)/2;i++){
MinMax(mini,maxi,&mini,&maxi);
v.push_back(mini);
v.push_back(maxi);
mini++;
maxi--;
}
}
else{
MinMax(mini,maxi,&mini,&maxi);
v.push_back(mini);
v.push_back(maxi);
ll buck=(maxi-mini+n-2)/(n-1)+1;
ll cur=mini,nex=mini+buck;
while(cur<=maxi){
ll x,y;
MinMax(cur,nex-1,&x,&y);
cur+=buck;
nex+=buck;
if (x>=0)
v.push_back(x);
if (y>=0)
v.push_back(y);
}
}
sort(v.begin(),v.end());
ll ans=0;
for(i=0;i<v.size()-1;i++)
ans=max(ans,v[i+1]-v[i]);
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:37:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | for(i=0;i<v.size()-1;i++)
| ~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
0 ms |
364 KB |
Output is correct |
9 |
Correct |
0 ms |
364 KB |
Output is correct |
10 |
Correct |
0 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
12 ms |
876 KB |
Output is correct |
17 |
Correct |
13 ms |
876 KB |
Output is correct |
18 |
Correct |
12 ms |
876 KB |
Output is correct |
19 |
Correct |
12 ms |
876 KB |
Output is correct |
20 |
Correct |
10 ms |
876 KB |
Output is correct |
21 |
Correct |
49 ms |
2276 KB |
Output is correct |
22 |
Correct |
49 ms |
2276 KB |
Output is correct |
23 |
Correct |
49 ms |
2276 KB |
Output is correct |
24 |
Correct |
50 ms |
2296 KB |
Output is correct |
25 |
Correct |
44 ms |
2276 KB |
Output is correct |
26 |
Correct |
49 ms |
2276 KB |
Output is correct |
27 |
Correct |
50 ms |
2404 KB |
Output is correct |
28 |
Correct |
49 ms |
2452 KB |
Output is correct |
29 |
Correct |
51 ms |
2276 KB |
Output is correct |
30 |
Correct |
40 ms |
2276 KB |
Output is correct |
31 |
Correct |
1 ms |
364 KB |
Output is correct |
32 |
Correct |
1 ms |
364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
0 ms |
364 KB |
Output is correct |
3 |
Correct |
0 ms |
364 KB |
Output is correct |
4 |
Correct |
0 ms |
364 KB |
Output is correct |
5 |
Correct |
0 ms |
364 KB |
Output is correct |
6 |
Correct |
1 ms |
364 KB |
Output is correct |
7 |
Correct |
1 ms |
364 KB |
Output is correct |
8 |
Correct |
1 ms |
364 KB |
Output is correct |
9 |
Correct |
1 ms |
364 KB |
Output is correct |
10 |
Correct |
1 ms |
364 KB |
Output is correct |
11 |
Correct |
1 ms |
364 KB |
Output is correct |
12 |
Correct |
1 ms |
364 KB |
Output is correct |
13 |
Correct |
1 ms |
364 KB |
Output is correct |
14 |
Correct |
1 ms |
364 KB |
Output is correct |
15 |
Correct |
1 ms |
364 KB |
Output is correct |
16 |
Correct |
15 ms |
876 KB |
Output is correct |
17 |
Correct |
16 ms |
876 KB |
Output is correct |
18 |
Correct |
16 ms |
876 KB |
Output is correct |
19 |
Correct |
17 ms |
876 KB |
Output is correct |
20 |
Correct |
8 ms |
492 KB |
Output is correct |
21 |
Correct |
64 ms |
2276 KB |
Output is correct |
22 |
Correct |
69 ms |
2300 KB |
Output is correct |
23 |
Correct |
64 ms |
2296 KB |
Output is correct |
24 |
Correct |
64 ms |
2388 KB |
Output is correct |
25 |
Correct |
65 ms |
3296 KB |
Output is correct |
26 |
Correct |
66 ms |
2276 KB |
Output is correct |
27 |
Correct |
65 ms |
2276 KB |
Output is correct |
28 |
Correct |
64 ms |
2344 KB |
Output is correct |
29 |
Correct |
66 ms |
2304 KB |
Output is correct |
30 |
Correct |
31 ms |
1516 KB |
Output is correct |
31 |
Correct |
0 ms |
364 KB |
Output is correct |
32 |
Correct |
0 ms |
364 KB |
Output is correct |