Submission #25399

#TimeUsernameProblemLanguageResultExecution timeMemory
25399khsoo01Watching (JOI13_watching)C++11
100 / 100
483 ms33472 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll inf = 1e18; ll n, x[2005], a, b, na[2005], nb[2005]; ll dt[2005][2005]; bool can (ll P) { for(ll i=1;i<=n;i++) { na[i] = lower_bound(x+1, x+1+n, x[i]+P) - x - 1; nb[i] = lower_bound(x+1, x+1+n, x[i]+2*P) - x - 1; for(ll j=0;j<=i;j++) dt[i][j] = inf; } for(ll i=1;i<=n;i++) { for(ll j=0;j<i;j++) { dt[na[i]][j] = min(dt[na[i]][j], dt[i-1][j] + 1); dt[nb[i]][j+1] = min(dt[nb[i]][j+1], dt[i-1][j]); } } for(ll i=0;i<=b;i++) if(dt[n][i] <= a) return true; return false; } int main() { scanf("%lld%lld%lld",&n,&a,&b); if(a + b >= n) {puts("1"); return 0;} for(ll i=1;i<=n;i++) scanf("%lld",&x[i]); sort(x+1, x+1+n); ll S = 1, E = inf; while(S<E) { ll M = (S+E)/2; can(M) ? E = M : S = M+1; } printf("%lld\n",S); }

Compilation message (stderr)

watching.cpp: In function 'int main()':
watching.cpp:26:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%lld",&n,&a,&b);
                                ^
watching.cpp:28:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(ll i=1;i<=n;i++) scanf("%lld",&x[i]);
                                          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...