Submission #197773

# Submission time Handle Problem Language Result Execution time Memory
197773 2020-01-22T22:53:55 Z Malomalomalomalo Watching (JOI13_watching) C++14
0 / 100
324 ms 16120 KB
#include <bits/stdc++.h>
#define gmin(x,y) x=min(x,y)
#define all(c) c.begin(), c.end()
using namespace std;

const int N = 2e3 + 5;

int dp[N][N];
const int inf = 1e9;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,p,q;	
	cin >> n >> p >> q;
	gmin(p,n);
	gmin(q,n);
	vector<int> pos(n+1);
	for(int i = 1;i <= n; ++i){
		cin >> pos[i];	
	}
	int l = 1, r = 1e9, ans = inf;
	while(l <= r){
		int m = l + (r-l)/2;
		for(int i = 0;i <= n; ++i){
			for(int j = 0;j <= n; ++j){
				dp[i][j] = inf;
			}
		}
		dp[0][0] = 0;
		for(int i = 0;i < n; ++i){
			int nxts = (int)(upper_bound(all(pos), pos[i+1] + m - 1) - pos.begin()) - 1;	
			int nxtl = (int)(upper_bound(all(pos), pos[i+1] + 2*m - 1) - pos.begin()) - 1;	
			for(int j = 0;j <= n; ++j){
				gmin(dp[nxts][j+1], dp[i][j]);
				gmin(dp[nxtl][j], dp[i][j] + 1);
			}
		}
		int mn = inf;
		for(int i = 0;i <= p; ++i){
			gmin(mn, dp[n][i]);
		}
		if(mn <= q){
			ans = m;
			r = m - 1;
		}
		else{
			l = m + 1;
		}
	}
	cout << ans << '\n';
}

# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 324 ms 16120 KB Output isn't correct
2 Halted 0 ms 0 KB -