This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/// gap
#include<bits/stdc++.h>
#include "gap.h"
using namespace std;
long long findGap(int T, int N)
{
long long s = 0, t = 1e18;
long long mn, mx;
vector < long long > fh, sh;
while(mn < mx)
{
MinMax(s, t, &mn, &mx);
if(mn == -1)break;
if(mn == mx)
{
fh.push_back(mn);
break;
}
if(mn > mx)break;
fh.push_back(mn);
sh.push_back(mx);
s = mn + 1;
t = mx - 1;
}
long long ans = 0;
for (int i = 1; i < fh.size(); ++ i)
ans = max(ans, fh[i] - fh[i-1]);
ans = max(ans, sh[0] - fh.back());
for (int i = 1; i < sh.size(); ++ i)
ans = max(ans, sh[i] - sh[i-1]);
return ans;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:28:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | for (int i = 1; i < fh.size(); ++ i)
| ~~^~~~~~~~~~~
gap.cpp:31:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | for (int i = 1; i < sh.size(); ++ i)
| ~~^~~~~~~~~~~
gap.cpp:12:11: warning: 'mn' is used uninitialized in this function [-Wuninitialized]
12 | while(mn < mx)
| ~~~^~~~
gap.cpp:12:11: warning: 'mx' is used uninitialized in this function [-Wuninitialized]
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |