제출 #242173

#제출 시각아이디문제언어결과실행 시간메모리
242173jiahngGap (APIO16_gap)C++14
0 / 100
79 ms1256 KiB
#include "gap.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 100001
#define INF (ll)1e18

long long findGap(int T, int N)
{
	ll mn=0,mx=0;
	MinMax(0LL,INF,&mn,&mx);
	
	ll lb = ceil(double(mx - mn + 1) / (double)N);
	
	ll cur = mn;
	ll ans = lb;
	
	ll prev;
	while (cur < mx){
		ll x,y;
		MinMax(cur,cur + lb - 1,&x,&y);
		if (x == -1){
			cur += lb;
			continue;
		}
		ans = max(ans,x - prev);
		prev = y;
		
		cur += lb - 1;
	}
	return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:41:19: warning: 'prev' may be used uninitialized in this function [-Wmaybe-uninitialized]
   ans = max(ans,x - prev);
                 ~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...