제출 #107413

#제출 시각아이디문제언어결과실행 시간메모리
107413yamamayumi9489Gap (APIO16_gap)C++14
30 / 100
87 ms4188 KiB
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>
 
using namespace std;
#define LL long long
#define ALF "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define LLBIG 1999999999999999999
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define VI vector<int>
#define VL vector<LL>
#define VVI vector<vector<int>>
 
#include"gap.h"
//MinMax(int,int,int&,int&)
 
long long findGap(int T, int N) {
	if (T == 1) {
		LL A[100002];
		LL l = 0, r = 1000000000000000000LL;
		for (int i = 0; i<(N + 1) / 2; i++) {
			MinMax(l, r, &A[i], &A[N - 1 - i]);
			l = A[i] + 1; r = A[N - 1 - i] - 1;
		}
 
		LL ans = 0;
		for (int i = 0; i<N - 1; i++)
			ans = max(ans, A[i + 1] - A[i]);
		return ans;
	}
	else if (T == 2) {
		VL A; LL mn, mx;
		MinMax(0, 1000000000000000000LL, &mn, &mx);
		LL l = mn + 1;
		LL r = mn + ((mx - mn + 1) / N);
		for (LL i = 0; i < N; i++) {
			LL a, b;
			MinMax(l, r, &a, &b);
			if (a != -1) {
				A.push_back(a);	A.push_back(b);
			}
			if(r == mx-1) break;
			l += ((mx - mn + 1) / N);
			r += ((mx - mn + 1) / N);
			r = min(r,mx-1);
		}
		sort(A.begin(), A.end());
		LL ans = 0;
		for (int i = 2; i < (int)A.size(); i += 2)
			ans = max(ans, A[i] - A[i - 1]);
		return ans;
	}
	else return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...