This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "gap.h"
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll t, n;
vector<ll> ve1, ve2, ve;
long long findGap(int T, int N)
{
t = T;
n = N;
if(t == 1)
{
ll ans = 0;
ll a, b;
MinMax(0LL, (ll)2e18, &a, &b);
ve1.push_back(a);
ve2.push_back(b);
for(ll i = 0; i < (n - 1) / 2; i++)
{
ll t1, t2;
MinMax(a + 1, b - 1, &t1, &t2);
ve1.push_back(t1);
ve2.push_back(t2);
a = t1, b = t2;
}
for(ll i = 1; i < ve1.size(); i++) ans = max(ans, ve1[i] - ve1[i - 1]);
for(ll i = 1; i < ve2.size(); i++) ans = max(ans, ve2[i - 1] - ve2[i]);
ans = max(ans, ve2[ve2.size() - 1] - ve1[ve1.size() - 1]);
return ans;
}
else
{
ll a, b;
MinMax(0LL, (ll)2e18, &a, &b);
ll c = (b - a + n - 2) / (n - 1);
ll ans = c;
ve.push_back(a);
for(ll i = a + 1; i <= b - 1; i += c)
{
ll t3 = -1, t4 = -1;
MinMax(i, min(i + c - 1, b - 1), &t3, &t4);
if(t3 != -1)
{
ve.push_back(t3);
ve.push_back(t4);
}
}
ve.push_back(b);
for(ll i = 1; i < ve.size(); i++)
{
ans = max(ans, ve[i] - ve[i - 1]);
}
return ans;
}
}
Compilation message (stderr)
gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:31:25: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | for(ll i = 1; i < ve1.size(); i++) ans = max(ans, ve1[i] - ve1[i - 1]);
| ~~^~~~~~~~~~~~
gap.cpp:32:25: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for(ll i = 1; i < ve2.size(); i++) ans = max(ans, ve2[i - 1] - ve2[i]);
| ~~^~~~~~~~~~~~
gap.cpp:54:25: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
54 | for(ll i = 1; i < ve.size(); i++)
| ~~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |