답안 #109906

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
109906 2019-05-08T11:16:34 Z cgiosy 구경하기 (JOI13_watching) C++17
0 / 100
10 ms 8292 KB
#include <cstdio>
#include <algorithm>
inline short min(const short x, const short y) { return x<y ? x : y; }
int a[2048], tx, ty; short d[2048][2048], n, x, y;
int main() {
	scanf("%hd%d%d", &n, &tx, &ty);
	y=ty<n?ty:n; x=tx<n-y?tx:n-y;
	for(int i=1; i<=n; i++) 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;
		for(int i=1; i<=n; i++) {
			while(p<=i && a[p]<=a[i]-m) p++;
			while(p<=i && a[q]<=a[i]-2*m) q++;
			for(int j=!i; j<=i && j<=x; j++) d[i][j]=i ? j ? 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

watching.cpp: In function 'int main()':
watching.cpp:6:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%hd%d%d", &n, &tx, &ty);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
watching.cpp:8:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1; i<=n; i++) scanf("%d", a+i);
                          ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 640 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 8292 KB Output isn't correct
2 Halted 0 ms 0 KB -