답안 #109896

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
109896 2019-05-08T10:56:59 Z cgiosy 구경하기 (JOI13_watching) C++17
50 / 100
29 ms 12476 KB
#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<x) x=n;
	rep(i, 1, n) scanf("%d", a+i);
	std::sort(a, a+n+1);

	int l=1, r=a[n]-a[1]+1;
	while(l<r) {
		int m=(l+r)/2, p=1, q=1;
		memset(d[1], 0x3f, 2047*2048*2);
		rep(i, 1, n) {
			while(p<=i && a[p]<=a[i]-m) p++;
			while(p<=i && a[q]<=a[i]-2*m) q++;
			rep(j, 1, x) d[i][j]=std::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);
}

Compilation message

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("%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);
               ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 8576 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 22 ms 8576 KB Output is correct
4 Correct 23 ms 8448 KB Output is correct
5 Correct 24 ms 8448 KB Output is correct
6 Correct 21 ms 8448 KB Output is correct
7 Correct 20 ms 8448 KB Output is correct
8 Correct 22 ms 8576 KB Output is correct
9 Correct 24 ms 8576 KB Output is correct
10 Correct 21 ms 8576 KB Output is correct
11 Correct 25 ms 8448 KB Output is correct
12 Correct 24 ms 8576 KB Output is correct
13 Correct 22 ms 8548 KB Output is correct
14 Correct 19 ms 8320 KB Output is correct
15 Correct 18 ms 8448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 29 ms 12476 KB Output isn't correct
2 Halted 0 ms 0 KB -