Submission #582110

#TimeUsernameProblemLanguageResultExecution timeMemory
582110urd05Sparklers (JOI17_sparklers)C++17
0 / 100
5 ms4180 KiB
#include <bits/stdc++.h> using namespace std; int n,k,t; long long arr[100000]; int dp[1000][1000]; long long s; int ans(int l,int r) { if (l==0&&r==n-1) { return 1; } if (dp[l][r]!=-1) { return dp[l][r]; } int ret=0; if (l!=0&&(arr[r]-arr[l-1])/s>=2*t*(r-l+1)){ ret|=ans(l-1,r); } if (r!=n-1&&(arr[r+1]-arr[l])/s>=2*t*(r-l+1)) { ret|=ans(l,r+1); } return dp[l][r]=ret; } bool isp(long long x) { s=x; memset(dp,-1,sizeof(dp)); return ans(k,k); } int main(void) { scanf("%d %d %d",&n,&k,&t); k--; for(int i=0;i<n;i++){ scanf("%lld",&arr[i]); } long long lo=0; long long hi=1e9; //possible while (lo+1<hi) { long long mid=(lo+hi)/2; if (isp(mid)) { hi=mid; } else { lo=mid; } } printf("%lld",hi); }

Compilation message (stderr)

sparklers.cpp: In function 'int main()':
sparklers.cpp:33:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     scanf("%d %d %d",&n,&k,&t);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         scanf("%lld",&arr[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...