제출 #401673

#제출 시각아이디문제언어결과실행 시간메모리
401673BERNARB01Gap (APIO16_gap)C++17
30 / 100
86 ms1956 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; long long findGap(int T, int N) { if (T == 1) { long long lb = 0, rb = (long long) 1e18L; vector<long long> a(N); for (int i = 0; i < (N + 1) / 2; i++) { MinMax(lb, rb, &a[i], &a[N - 1 - i]); lb = a[i] + 1; rb = a[N - 1 - i] - 1; } long long ans = 0; for (int i = 1; i < N; i++) { ans = max(ans, a[i] - a[i - 1]); } return ans; } long long lb = 0, rb = (long long) 1e18L; vector<long long> a(N); for (int i = 0; i < (N + 1) / 2; i++) { MinMax(lb, rb, &a[i], &a[N - 1]); lb = a[i] + 1; } rb = a[N - 1] - 1; for (int i = N - 2; i >= (N + 1) / 2; i--) { MinMax(0LL, rb, &a[0], &a[i]); rb = a[i] - 1; } long long ans = 0; for (int i = 1; i < N; i++) { ans = max(ans, a[i] - a[i - 1]); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...