제출 #109888

#제출 시각아이디문제언어결과실행 시간메모리
109888cgiosy구경하기 (JOI13_watching)C++17
0 / 100
174 ms8412 KiB
#include <cstdio> #include <algorithm> #define rep(i,x,n) for(int i=x; i<=n; i++) inline short min(const short x, const short y) { return x<y ? x : y; } int a[2048]; short d[2048][2048], n, x, y; int main() { scanf("%hd%hd%hd", &n, &x, &y); if(n<x) x=n; rep(i, 1, n) scanf("%d", a+i); std::sort(a, a+n+1); int l=0, r=1e9; while(l<r) { int m=(l+r)/2, p=1, q=1; rep(i, 1, n) rep(j, 0, x) d[i][j]=n; rep(i, 1, n) { while(a[p]<a[i]-m) p++; while(a[q]<a[i]-2*m) q++; rep(j, 1, x) d[i][j]=min(d[p-1][j-1], d[q-1][j]+1); } if(d[n][x]<=y) r=m; else l=m+1; } printf("%d", r+1); }

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

watching.cpp: In function 'int main()':
watching.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%hd%hd%hd", &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...