Submission #499101

#TimeUsernameProblemLanguageResultExecution timeMemory
499101KiprasSwimming competition (LMIO18_plaukimo_varzybos)C++14
0 / 100
992 ms4612 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; const int maxN = 1e6+10; const int inf = 2147000000; int n, mini, maxi; int a[maxN]; int dp[maxN]; bool test(int v){ fill(dp, dp+maxN, 0); dp[0]=1; int i, j; for(i = 0; i < n; i++){ if(i>1)dp[i]+=dp[i-1]; if(dp[i]<=0)continue; j=i; while(j<n&&a[j]-a[i]<=v)j++; if(i+mini<=min(i+maxi, j)){ dp[i+mini]++; dp[min(i+maxi, j)+1]--; } } dp[n]+=dp[n-1]; return dp[n]>0; } int solve(){ int l = 0, h = inf; while(l<h-1){ int mid = l+((h-l)/2); //cout<<l<<" "<<mid<<" "<<h<<" "<<test(mid)<<endl; if(test(mid))h=mid; else l=mid; } return h; } int main() { ios_base::sync_with_stdio(0);cin.tie(nullptr); cin>>n>>mini>>maxi; for(int i = 0; i < n; i++)cin>>a[i]; sort(a, a+n); cout<<solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...