Submission #109901

#TimeUsernameProblemLanguageResultExecution timeMemory
109901cgiosy구경하기 (JOI13_watching)C++17
100 / 100
259 ms16476 KiB
#include <cstdio> #include <cstring> #include <algorithm> #define rep(i,x,n) for(int i=x; i<=n; i++) int a[2048], d[2048][2048], n, x, y; int main() { scanf("%d%d%d", &n, &x, &y); if(n<y) y=n; if(n-y<x) x=n-y; rep(i, 1, n) scanf("%d", a+i); std::sort(a+1, a+n+1); int l=1, r=a[n]-a[1]+1; while(l<r) { int m=(l+r)/2, p=0, q=0; rep(i, 0, n) { while(p<=i && a[p]<=a[i]-m) p++; while(p<=i && a[q]<=a[i]-2*m) q++; rep(j, !i, x) d[i][j]=i ? j ? std::min(d[p-1][j-1], d[q-1][j]+1) : d[q-1][j]+1 : 0; } if(d[n][x]<=y) r=m; else l=m+1; } printf("%d", r); }

Compilation message (stderr)

watching.cpp: In function 'int main()':
watching.cpp:9:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  if(n<y) y=n; if(n-y<x) x=n-y;
  ^~
watching.cpp:9:15: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  if(n<y) y=n; if(n-y<x) x=n-y;
               ^~
watching.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &n, &x, &y);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
watching.cpp:10:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  rep(i, 1, n) scanf("%d", a+i);
               ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...