제출 #262492

#제출 시각아이디문제언어결과실행 시간메모리
262492yuma220284Gap (APIO16_gap)C++14
30 / 100
84 ms1952 KiB
#include "gap.h" #include <iostream> #include <vector> #include <algorithm> using namespace std; long long findGap(int T, int N) { if (T == 1) { vector<long long> A(N); long long L = 0, R = 1000000000000000000; for (int i = 0; i < (N + 1) / 2; i++) { long long MN, MX; MinMax(L, R, &MN, &MX); A[i] = MN, A[N - 1 - i] = MX; L = MN + 1, R = MX - 1; } long long ANS = 0; for (int i = 0; i < N - 1; i++) { ANS = max(ANS, A[i + 1] - A[i]); } return ANS; } else { long long L = 0, R = 1000000000000000000; long long MN, MX; MinMax(L, R, &MN, &MX); L = MN, R = MX; long long Size = (R - L + N - 2) / (N - 1); MinMax(L, L + Size - 1, &MN, &MX); long long Cur = MX; long long ANS = 0; for (long long i = 1; i < N - 1; i++) { MinMax(L + Size * i, L + Size * (i + 1) - 1, &MN, &MX); if (MN != -1) { ANS = max(ANS, MN - Cur); Cur = MX; } } return ANS; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...