Submission #498913

#TimeUsernameProblemLanguageResultExecution timeMemory
498913KiprasSwimming competition (LMIO18_plaukimo_varzybos)C++14
0 / 100
1 ms204 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]; bool test(int v){ int i=0, j=0; bool pos=true; while(j<n&&pos){ if(i-j==maxi){i=j;/*cout<<i<<" "<<j<<" "<<a[j]-a[i]<<endl;*/} if(a[j]-a[i]>v){ if(j-i<mini)pos=false; else {i=j;/*cout<<i<<" "<<j<<" "<<a[j]-a[i]<<endl;*/} }else j++; } if(n-i<mini)pos=false; return pos; } int solve(){ int ans=inf; int l = 0, h = a[n-1]-a[0]; while(l<h){ int mid = l+((h-l)/2); if(test(mid))h=mid; else l=mid+1; } return l; } 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<<test(3); cout<<solve(); return 0; }

Compilation message (stderr)

plaukimo_varzybos.cpp: In function 'int solve()':
plaukimo_varzybos.cpp:28:9: warning: unused variable 'ans' [-Wunused-variable]
   28 |     int ans=inf;
      |         ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...