Submission #25404

# Submission time Handle Problem Language Result Execution time Memory
25404 2017-06-22T04:41:01 Z 서규호(#1066) Watching (JOI13_watching) C++14
100 / 100
186 ms 17684 KB
#include <bits/stdc++.h>

#define lld long long
#define pp pair<int,int>
#define pb push_back
#define MOD 10007
#define left lleft
#define right rright
#define INF 2000000000
#define Linf 1000000000000000000LL
#define next nnext

using namespace std;

int N,P,Q,ans;
int a[2002];
int d[2002][2002];

bool process(int w){
	for(int i=1; i<=N; i++){
		int it1 = lower_bound(a,a+N+1,a[i]-w+1)-a;
		int it2 = lower_bound(a,a+N+1,a[i]-w*2+1)-a;
		it1 = max(it1-1,0); it2 = max(it2-1,0);
		d[i][0] = d[it1][0]+1;
		for(int j=1; j<=Q; j++){
			d[i][j] = min(d[it1][j]+1,d[it2][j-1]);
		}
	}
	return d[N][Q] <= P;
}

int main(){
	scanf("%d %d %d",&N,&P,&Q);
	for(int i=1; i<=N; i++) scanf("%d",&a[i]);
	sort(a+1,a+N+1);
	int l = 1,r = INF/2;
	P = min(P,N); Q = min(Q,N);
	while(l <= r){
		int mid = (l+r)/2;
		if(process(mid)){
			ans = mid;
			r = mid-1;
		}else l = mid+1;
	}
	printf("%d\n",ans);

	return 0;
}

Compilation message

watching.cpp: In function 'int main()':
watching.cpp:33:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %d",&N,&P,&Q);
                            ^
watching.cpp:34:43: 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]);
                                           ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 17684 KB Output is correct
2 Correct 0 ms 17684 KB Output is correct
3 Correct 0 ms 17684 KB Output is correct
4 Correct 0 ms 17684 KB Output is correct
5 Correct 0 ms 17684 KB Output is correct
6 Correct 0 ms 17684 KB Output is correct
7 Correct 0 ms 17684 KB Output is correct
8 Correct 0 ms 17684 KB Output is correct
9 Correct 0 ms 17684 KB Output is correct
10 Correct 0 ms 17684 KB Output is correct
11 Correct 0 ms 17684 KB Output is correct
12 Correct 0 ms 17684 KB Output is correct
13 Correct 0 ms 17684 KB Output is correct
14 Correct 0 ms 17684 KB Output is correct
15 Correct 0 ms 17684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 17684 KB Output is correct
2 Correct 0 ms 17684 KB Output is correct
3 Correct 126 ms 17684 KB Output is correct
4 Correct 9 ms 17684 KB Output is correct
5 Correct 163 ms 17684 KB Output is correct
6 Correct 186 ms 17684 KB Output is correct
7 Correct 3 ms 17684 KB Output is correct
8 Correct 66 ms 17684 KB Output is correct
9 Correct 19 ms 17684 KB Output is correct
10 Correct 16 ms 17684 KB Output is correct
11 Correct 176 ms 17684 KB Output is correct
12 Correct 89 ms 17684 KB Output is correct
13 Correct 9 ms 17684 KB Output is correct
14 Correct 9 ms 17684 KB Output is correct
15 Correct 9 ms 17684 KB Output is correct