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 = (long long)1e18;
long long mn, mx;
vector < long long > fh, sh;
while(s < t)
{
///cout << mn << " " << mx << endl;
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;
}
reverse(sh.begin(), sh.end());
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]);
//cout << ans << endl;
return ans;
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for (int i = 1; i < fh.size(); ++ i)
| ~~^~~~~~~~~~~
gap.cpp:32:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for (int i = 1; i < sh.size(); ++ i)
| ~~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |