# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
338997 |
2020-12-24T10:59:13 Z |
ogibogi2004 |
Gap (APIO16_gap) |
C++14 |
|
69 ms |
3296 KB |
#include<bits/stdc++.h>
#include "gap.h"
using namespace std;
long long findGap(int T,int N)
{
long long l,r,n=N;
if(T==1)
{
MinMax(0ll,(long long)1e18,&l,&r);
vector<long long> numbers;
numbers.push_back(l);
numbers.push_back(r);
//cout<<l<<" "<<r<<endl;
for(int j=1;j<(n+1)/2;j++)
{
MinMax(l+1,r-1,&l,&r);
if(l==-1)break;
numbers.push_back(l);
numbers.push_back(r);
//cout<<"??\n";
}
sort(numbers.begin(),numbers.end());
long long ans=0;
for(long long i=1;i<numbers.size();i++)
{
ans=max(ans,numbers[i]-numbers[i-1]);
}
return ans;
}
if(T==2)
{
MinMax(0ll,(long long)1e18,&l,&r);
if(n==2)
{
return r-l;
}
long long l1=l+1,r1=r-1,bucket_size=(r1-l1+n-3)/(n-2);
vector<long long>numbers;
numbers.push_back(l);
for(long long i=0;i*bucket_size+l1<r1;i++)
{
long long xd1,xd2;
MinMax(i*bucket_size+l1,min(r1,(i+1)*bucket_size+l1-1),&xd1,&xd2);
if(xd1!=-1)numbers.push_back(xd1);
if(xd2!=-1)numbers.push_back(xd2);
}
numbers.push_back(r);
long long ans=0;
for(long long i=1;i<numbers.size();i++)
{
ans=max(ans,numbers[i]-numbers[i-1]);
}
return ans;
}
}
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:24:22: 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]
24 | for(long long i=1;i<numbers.size();i++)
| ~^~~~~~~~~~~~~~~
gap.cpp:49:22: 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]
49 | for(long long i=1;i<numbers.size();i++)
| ~^~~~~~~~~~~~~~~
gap.cpp:55:1: warning: control reaches end of non-void function [-Wreturn-type]
55 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
364 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
364 KB |
Output is correct |
5 |
Correct |
1 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 |
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 |
2 ms |
364 KB |
Output is correct |
15 |
Correct |
2 ms |
364 KB |
Output is correct |
16 |
Correct |
13 ms |
876 KB |
Output is correct |
17 |
Correct |
13 ms |
876 KB |
Output is correct |
18 |
Correct |
14 ms |
876 KB |
Output is correct |
19 |
Correct |
14 ms |
876 KB |
Output is correct |
20 |
Correct |
11 ms |
876 KB |
Output is correct |
21 |
Correct |
56 ms |
2276 KB |
Output is correct |
22 |
Correct |
50 ms |
2276 KB |
Output is correct |
23 |
Correct |
55 ms |
2296 KB |
Output is correct |
24 |
Correct |
50 ms |
2276 KB |
Output is correct |
25 |
Correct |
45 ms |
2276 KB |
Output is correct |
26 |
Correct |
49 ms |
2276 KB |
Output is correct |
27 |
Correct |
51 ms |
2272 KB |
Output is correct |
28 |
Correct |
53 ms |
2276 KB |
Output is correct |
29 |
Correct |
50 ms |
2444 KB |
Output is correct |
30 |
Correct |
49 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 |
1 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 |
1 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 |
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 |
15 ms |
876 KB |
Output is correct |
17 |
Correct |
17 ms |
1084 KB |
Output is correct |
18 |
Correct |
17 ms |
876 KB |
Output is correct |
19 |
Correct |
15 ms |
876 KB |
Output is correct |
20 |
Correct |
7 ms |
492 KB |
Output is correct |
21 |
Correct |
63 ms |
2276 KB |
Output is correct |
22 |
Correct |
63 ms |
2276 KB |
Output is correct |
23 |
Correct |
67 ms |
2276 KB |
Output is correct |
24 |
Correct |
66 ms |
2288 KB |
Output is correct |
25 |
Correct |
69 ms |
3296 KB |
Output is correct |
26 |
Correct |
64 ms |
2276 KB |
Output is correct |
27 |
Correct |
64 ms |
2276 KB |
Output is correct |
28 |
Correct |
65 ms |
2276 KB |
Output is correct |
29 |
Correct |
64 ms |
2276 KB |
Output is correct |
30 |
Correct |
35 ms |
1756 KB |
Output is correct |
31 |
Correct |
1 ms |
364 KB |
Output is correct |
32 |
Correct |
1 ms |
364 KB |
Output is correct |