Submission #160838

#TimeUsernameProblemLanguageResultExecution timeMemory
160838nafis_shifatGap (APIO16_gap)C++14
70 / 100
86 ms3176 KiB
#include "gap.h"
#include<bits/stdc++.h>
#define pii pair<int,int>
#define ll long long
using namespace std;

const ll inf=1e18;
long long findGap(int T, int N)
{
	ll mx,mn;
	mx=mn=-1;

	MinMax(0,inf,&mn,&mx);


	ll sm=mn;
	ll up=mx;
	ll off=(mx-mn-1)/N;

	ll lst=sm;
	ll cur=0;

	ll pnt=sm+1;
	
	for(int i=1;i<N;i++)
	{

		MinMax(pnt,pnt+off-1,&mn,&mx);
		if(mn!=-1)
		{
			cur=max(cur,mn-lst);
			lst=mx;
		}
		pnt+=off;
	}

	MinMax(pnt,up-1,&mn,&mx);

	if(mn!=-1)
	{
		cur=max(cur,mn-lst);
		cur=max(cur,up-mx);
	}
	else
	{
		cur=max(cur,up-lst);
	}


	return cur;





}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...