Submission #564447

#TimeUsernameProblemLanguageResultExecution timeMemory
564447penguin133Gap (APIO16_gap)C++14
30 / 100
69 ms1864 KiB
#include "gap.h" #include <bits/stdc++.h> using namespace std; long long B[100005]; long long findGap(int T, int N) { if(T == 1){ long long ans = 0, mini, maxi; B[N+1] = (long long)1e18 + 5, B[0] = -1; int j = N; for(int i=1;i<=j;i++){ //cout << B[i-1] << " " << B[j+1] << '\n'; MinMax(B[i-1]+1, B[j+1]-1, &mini, &maxi); //cout << mini << '\n'; B[i] = mini, B[j] = maxi; //cout << *mini << " " << *maxi << '\n'; j--; } for(int i=1;i<N;i++)ans = max(ans, B[i+1] - B[i]); return ans; } else{ long long ans = 0, mini, maxi; MinMax(0, (long long)1e18, &mini, &maxi); long long tmp = maxi - mini - 1; if(N == 2)return maxi-mini; long long prev = mini, prev2 = mini; for(int i=1;i<=N-1;i++){ long long x = tmp/(N-i); tmp -= x; MinMax(prev2 + 1, prev2 + x, &mini, &maxi); //cout << prev2 + 1 << " " << prev2 + x << " " << mini << " " << maxi << '\n'; if(mini != -1)ans = max(ans, mini - prev), prev = maxi; prev2 += x; } return ans; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...