제출 #499110

#제출 시각아이디문제언어결과실행 시간메모리
499110KiprasSwimming competition (LMIO18_plaukimo_varzybos)C++14
0 / 100
5 ms4172 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=max(j, i+1); 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 = -1, h = inf; while(l<h-1){ int mid = (h+l)/2; 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; }

컴파일 시 표준 에러 (stderr) 메시지

plaukimo_varzybos.cpp: In function 'bool test(int)':
plaukimo_varzybos.cpp:19:12: warning: 'j' may be used uninitialized in this function [-Wmaybe-uninitialized]
   19 |     int i, j;
      |            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...