제출 #257101

#제출 시각아이디문제언어결과실행 시간메모리
257101EntityITGap (APIO16_gap)C++14
70 / 100
79 ms1280 KiB
#include <bits/stdc++.h> using namespace std; #define ALL(x) (x).begin(), (x).end() #define SZ(x) static_cast<int>((x).size()) template<class T, size_t D> struct vec : vector<vec<T, D - 1>> { template<class... Args> vec(size_t n = 0, Args... args) : vector<vec<T, D - 1>>(n, vec<T, D - 1>(args...)) {} }; template<class T> struct vec<T, 1> : vector<T> { template<class... Args> vec(Args... args) : vector<T>(args...) {} }; template<class T> inline bool Minimize(T& a, const T& b) { return a > b ? a = b, true : false; } template<class T> inline bool Maximize(T& a, const T& b) { return a < b ? a = b, true : false; } inline int Next(int i, int n) { return i == n - 1 ? 0 : i + 1; } inline int Prev(int i, int n) { return !i ? n - 1 : i - 1; } mt19937 rng(static_cast<uint32_t>(chrono::steady_clock::now().time_since_epoch().count())); #include "gap.h" long long findGap(int subtask, int n) { long long min_value, max_value, answer; MinMax(0, static_cast<long long>(1e18), &min_value, &max_value); auto max_a = max_value; auto const magic = (max_value - min_value + n - 2) / (n - 1); answer = magic; for (long long left_value = min_value + 1, right_value = min_value + magic, last_value = min_value; left_value <= max_a; left_value += magic, right_value += magic) { MinMax(left_value, right_value, &min_value, &max_value); if (~min_value) { Maximize(answer, min_value - last_value); last_value = max_value; } } return answer; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...