# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
646386 |
2022-09-29T17:34:46 Z |
Tenis0206 |
Gap (APIO16_gap) |
C++11 |
|
61 ms |
3124 KB |
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
long long n;
long long bck = 1000;
long long pmax = 0;
long long solve1()
{
int l = 1;
int r = n;
long long st = 0, dr = 1e18;
vector<long long> a,b;
while(l<=r)
{
long long x,y;
MinMax(st,dr,&x,&y);
a.push_back(x);
b.push_back(y);
++l;
--r;
st = x + 1;
dr = y - 1;
}
vector<long long> v;
for(auto it : a)
{
v.push_back(it);
}
reverse(b.begin(),b.end());
for(auto it : b)
{
v.push_back(it);
}
long long Max = 0;
for(int i=1;i<v.size();i++)
{
Max = max(Max,v[i] - v[i-1]);
}
return Max;
}
long long solve2(long long st, long long dr)
{
MinMax(st,dr,&st,&dr);
long long pmax = (dr - st + n - 2) / (n - 1);
long long last = -1;
long long rez = -1;
if(n==2)
{
return dr - st;
}
while(st<=dr)
{
long long l = st;
long long r = min(dr,l + pmax);
MinMax(l,r,&l,&r);
if(l!=-1 && last!=-1)
{
rez = max(rez,l-last);
}
if(l!=-1)
{
last = r;
}
st += pmax + 1;
}
return rez;
}
long long findGap(int t, int N)
{
n = N;
if(t==1)
{
return solve1();
}
return solve2(1,1e18);
}
Compilation message
gap.cpp: In function 'long long int solve1()':
gap.cpp:39:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for(int i=1;i<v.size();i++)
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
288 KB |
Output is correct |
3 |
Correct |
1 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
1 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
2 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Correct |
1 ms |
336 KB |
Output is correct |
14 |
Correct |
1 ms |
336 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
9 ms |
1136 KB |
Output is correct |
17 |
Correct |
9 ms |
1132 KB |
Output is correct |
18 |
Correct |
10 ms |
1104 KB |
Output is correct |
19 |
Correct |
10 ms |
1132 KB |
Output is correct |
20 |
Correct |
7 ms |
1104 KB |
Output is correct |
21 |
Correct |
36 ms |
3052 KB |
Output is correct |
22 |
Correct |
39 ms |
3124 KB |
Output is correct |
23 |
Correct |
38 ms |
3020 KB |
Output is correct |
24 |
Correct |
39 ms |
2980 KB |
Output is correct |
25 |
Correct |
31 ms |
3016 KB |
Output is correct |
26 |
Correct |
36 ms |
3000 KB |
Output is correct |
27 |
Correct |
39 ms |
3012 KB |
Output is correct |
28 |
Correct |
36 ms |
3004 KB |
Output is correct |
29 |
Correct |
36 ms |
2984 KB |
Output is correct |
30 |
Correct |
29 ms |
3012 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
0 ms |
208 KB |
Output is correct |
3 |
Correct |
0 ms |
208 KB |
Output is correct |
4 |
Correct |
0 ms |
208 KB |
Output is correct |
5 |
Correct |
0 ms |
208 KB |
Output is correct |
6 |
Correct |
0 ms |
208 KB |
Output is correct |
7 |
Correct |
0 ms |
208 KB |
Output is correct |
8 |
Correct |
0 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
0 ms |
208 KB |
Output is correct |
11 |
Correct |
1 ms |
208 KB |
Output is correct |
12 |
Correct |
1 ms |
208 KB |
Output is correct |
13 |
Correct |
1 ms |
208 KB |
Output is correct |
14 |
Correct |
1 ms |
208 KB |
Output is correct |
15 |
Correct |
1 ms |
208 KB |
Output is correct |
16 |
Correct |
12 ms |
432 KB |
Output is correct |
17 |
Correct |
12 ms |
464 KB |
Output is correct |
18 |
Correct |
12 ms |
464 KB |
Output is correct |
19 |
Correct |
12 ms |
512 KB |
Output is correct |
20 |
Correct |
6 ms |
464 KB |
Output is correct |
21 |
Correct |
53 ms |
1076 KB |
Output is correct |
22 |
Correct |
50 ms |
1080 KB |
Output is correct |
23 |
Correct |
51 ms |
1076 KB |
Output is correct |
24 |
Correct |
52 ms |
1076 KB |
Output is correct |
25 |
Correct |
47 ms |
1080 KB |
Output is correct |
26 |
Correct |
50 ms |
960 KB |
Output is correct |
27 |
Correct |
50 ms |
1060 KB |
Output is correct |
28 |
Correct |
61 ms |
1076 KB |
Output is correct |
29 |
Correct |
50 ms |
1076 KB |
Output is correct |
30 |
Correct |
24 ms |
996 KB |
Output is correct |
31 |
Correct |
0 ms |
208 KB |
Output is correct |
32 |
Correct |
0 ms |
208 KB |
Output is correct |