# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
751228 |
2023-05-31T08:34:10 Z |
sofija6 |
Gap (APIO16_gap) |
C++14 |
|
61 ms |
2260 KB |
#include <bits/stdc++.h>
#include "gap.h"
using namespace std;
long long findGap(int T, int N)
{
if (T==1)
{
long long l=0,r=1e18,ans=-1;
vector<long long> a;
while (true)
{
if (l>r || a.size()==N)
break;
long long curl,curr;
MinMax(l,r,&curl,&curr);
if (curl==-1)
break;
a.push_back(curl);
if (curr!=curl)
a.push_back(curr);
l=curl+1;
r=curr-1;
}
sort(a.begin(),a.end());
for (long long i=1;i<a.size();i++)
ans=max(ans,a[i]-a[i-1]);
return ans;
}
long long l,r,avg,curl,curr,ans=-1;
MinMax(0,1e18,&l,&r);
avg=(r-l+N-2)/(N-1);
vector<long long> a;
while (true)
{
if (l>r)
break;
MinMax(l,l+avg,&curl,&curr);
if (curl==-1)
{
l+=avg+1;
continue;
}
a.push_back(curl);
if (curr!=curl)
a.push_back(curr);
l+=avg+1;
}
for (long long i=1;i<a.size();i++)
ans=max(ans,a[i]-a[i-1]);
return ans;
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:14:32: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
14 | if (l>r || a.size()==N)
| ~~~~~~~~^~~
gap.cpp:27:29: 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]
27 | for (long long i=1;i<a.size();i++)
| ~^~~~~~~~~
gap.cpp:50:25: 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]
50 | for (long long i=1;i<a.size();i++)
| ~^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 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 |
1 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 |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
2 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 |
11 ms |
848 KB |
Output is correct |
17 |
Correct |
11 ms |
876 KB |
Output is correct |
18 |
Correct |
10 ms |
848 KB |
Output is correct |
19 |
Correct |
12 ms |
848 KB |
Output is correct |
20 |
Correct |
8 ms |
848 KB |
Output is correct |
21 |
Correct |
41 ms |
2208 KB |
Output is correct |
22 |
Correct |
41 ms |
2136 KB |
Output is correct |
23 |
Correct |
44 ms |
2220 KB |
Output is correct |
24 |
Correct |
41 ms |
2200 KB |
Output is correct |
25 |
Correct |
42 ms |
2132 KB |
Output is correct |
26 |
Correct |
41 ms |
2256 KB |
Output is correct |
27 |
Correct |
45 ms |
2200 KB |
Output is correct |
28 |
Correct |
41 ms |
2240 KB |
Output is correct |
29 |
Correct |
41 ms |
2208 KB |
Output is correct |
30 |
Correct |
35 ms |
2136 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 |
1 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 |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
0 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Correct |
1 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 |
13 ms |
808 KB |
Output is correct |
17 |
Correct |
13 ms |
900 KB |
Output is correct |
18 |
Correct |
13 ms |
888 KB |
Output is correct |
19 |
Correct |
12 ms |
848 KB |
Output is correct |
20 |
Correct |
6 ms |
464 KB |
Output is correct |
21 |
Correct |
59 ms |
2188 KB |
Output is correct |
22 |
Correct |
52 ms |
2152 KB |
Output is correct |
23 |
Correct |
61 ms |
2240 KB |
Output is correct |
24 |
Correct |
54 ms |
2204 KB |
Output is correct |
25 |
Correct |
49 ms |
2240 KB |
Output is correct |
26 |
Correct |
58 ms |
2208 KB |
Output is correct |
27 |
Correct |
52 ms |
2260 KB |
Output is correct |
28 |
Correct |
52 ms |
2188 KB |
Output is correct |
29 |
Correct |
59 ms |
2224 KB |
Output is correct |
30 |
Correct |
27 ms |
1468 KB |
Output is correct |
31 |
Correct |
1 ms |
208 KB |
Output is correct |
32 |
Correct |
1 ms |
208 KB |
Output is correct |