# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
219833 |
2020-04-06T13:28:49 Z |
MKopchev |
Gap (APIO16_gap) |
C++14 |
|
82 ms |
3412 KB |
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;
const long long nmax=1e5+42,inf=1e18+42;
int n;
long long inp[nmax];
/*
void MinMax(long long low,long long up,long long &a,long long &b)
{
cout<<low<<" "<<up<<endl;
cin>>a;
cin>>b;
}
*/
void ask(long long low,long long up,long long &mini,long long &maxi)
{
MinMax(low,up,&mini,&maxi);//!
}
long long findGap(int T,int N)
{
n=N;
long long mini,maxi;
ask(0,inf,mini,maxi);
//cout<<"mini= "<<mini<<" maxi= "<<maxi<<endl;
if(T==1)
{
inp[1]=mini;
inp[n]=maxi;
for(int le=2;le<=n+1-le;le++)
{
int ri=n+1-le;
ask(inp[le-1]+1,inp[ri+1]-1,mini,maxi);
inp[le]=mini;
inp[ri]=maxi;
}
long long ret=0;
for(int i=2;i<=n;i++)
ret=max(ret,inp[i]-inp[i-1]);
return ret;
}
//T=2
if(n==2)return maxi-mini;
long long low=(maxi-mini)/(n-1);
vector<long long> noted={mini,maxi};
for(long long mini_new=mini+1;mini_new<=noted[1];mini_new+=(low+1))
{
ask(mini_new,mini_new+low,mini,maxi);
if(mini!=-1){noted.push_back(mini);noted.push_back(maxi);}
}
sort(noted.begin(),noted.end());
long long ret=0;
for(int i=1;i<noted.size();i++)
ret=max(ret,noted[i]-noted[i-1]);
return ret;
}
/*
int main()
{
cout<<findGap(2,4)<<endl;
}
*/
Compilation message
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:63:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=1;i<noted.size();i++)
~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 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 |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
4 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
344 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 |
16 ms |
768 KB |
Output is correct |
17 |
Correct |
19 ms |
764 KB |
Output is correct |
18 |
Correct |
17 ms |
768 KB |
Output is correct |
19 |
Correct |
17 ms |
768 KB |
Output is correct |
20 |
Correct |
13 ms |
768 KB |
Output is correct |
21 |
Correct |
53 ms |
1904 KB |
Output is correct |
22 |
Correct |
54 ms |
1912 KB |
Output is correct |
23 |
Correct |
64 ms |
1912 KB |
Output is correct |
24 |
Correct |
55 ms |
1916 KB |
Output is correct |
25 |
Correct |
46 ms |
1784 KB |
Output is correct |
26 |
Correct |
54 ms |
1912 KB |
Output is correct |
27 |
Correct |
59 ms |
1992 KB |
Output is correct |
28 |
Correct |
54 ms |
1912 KB |
Output is correct |
29 |
Correct |
55 ms |
1912 KB |
Output is correct |
30 |
Correct |
46 ms |
2040 KB |
Output is correct |
31 |
Correct |
4 ms |
384 KB |
Output is correct |
32 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
4 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 |
4 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
4 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
6 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 |
20 ms |
1024 KB |
Output is correct |
17 |
Correct |
23 ms |
1024 KB |
Output is correct |
18 |
Correct |
20 ms |
1024 KB |
Output is correct |
19 |
Correct |
20 ms |
896 KB |
Output is correct |
20 |
Correct |
12 ms |
640 KB |
Output is correct |
21 |
Correct |
72 ms |
2276 KB |
Output is correct |
22 |
Correct |
70 ms |
2268 KB |
Output is correct |
23 |
Correct |
71 ms |
2288 KB |
Output is correct |
24 |
Correct |
72 ms |
2288 KB |
Output is correct |
25 |
Correct |
74 ms |
3412 KB |
Output is correct |
26 |
Correct |
74 ms |
2288 KB |
Output is correct |
27 |
Correct |
82 ms |
2288 KB |
Output is correct |
28 |
Correct |
71 ms |
2364 KB |
Output is correct |
29 |
Correct |
78 ms |
2292 KB |
Output is correct |
30 |
Correct |
38 ms |
1528 KB |
Output is correct |
31 |
Correct |
4 ms |
384 KB |
Output is correct |
32 |
Correct |
4 ms |
384 KB |
Output is correct |