제출 #30926

#제출 시각아이디문제언어결과실행 시간메모리
30926sean617Gap (APIO16_gap)C++98
100 / 100
89 ms6704 KiB
#include "gap.h"
#include <algorithm>
#include <vector>
typedef long long ll;

using namespace std;
ll n, x = -1, a[100005];
vector<ll> b;
long long findGap(int T, int N)
{
	ll st = 0, en = 1e18, i = 0, j = N - 1, mn, mx, ans;
	if (T == 1) {
		while (i <= j) {
			MinMax(st, en, &mn, &mx);
			a[i] = mn;
			a[j] = mx;
			st = mn + 1;
			en = mx - 1;
			i++;
			j--;
		}
		ans = a[1] - a[0];
		for (i = 1; i < N - 1; i++) {
			ans = max(ans, a[i + 1] - a[i]);
		}
	} else {
		MinMax(st, en, &mn, &mx);
		x = (mx - mn) / (N - 1);
		if ((mx - mn) % (N - 1) > 0) x++;
		st = mn;
		en = mx;
		for (i = st; i <= en; i += x + 1) {
			j = min(i + x, en);
			MinMax(i, j, &mn, &mx);
			if (mn != -1) {
				b.push_back(mn);
				if (mx != mn) b.push_back(mx);
			}
		}
		ans = x;
		for (i = 0; i < b.size() - 1; i++) {
			ans = max(ans, b[i + 1] - b[i]);
		}
	}
	return ans;
}

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

gap.cpp: In function 'long long int findGap(int, int)':
gap.cpp:41:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (i = 0; i < b.size() - 1; i++) {
                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...