Submission #468517

# Submission time Handle Problem Language Result Execution time Memory
468517 2021-08-28T15:53:39 Z mychecksedad Watching (JOI13_watching) C++17
0 / 100
2 ms 844 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 110, MX = 1e9;

int n, p, q, arr[N], dp[N][N][N][2];
bool check(int w){
	for(int i = 0; i <= n+1; i++) for(int j = 0; j <= p+1; j++) for(int k = 0; k <= q+1; k++) dp[i][j][k][0] = dp[i][j][k][1] = -1;
	dp[0][0][0][0] = 0;
	dp[0][0][0][1] = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= p; j++){
			for(int k = 0; k <= q; k++){
				if(k==j&&k==0) continue;
				if(j > 0 && (dp[i - 1][j - 1][k][0] > -1 || dp[i - 1][j - 1][k][1] > -1)){
					dp[i][j][k][0] = arr[i] + w;
					dp[i][j][k][1] = arr[i] + 2 * w;
				}
				if(k > 0 && (dp[i - 1][j][k - 1][0] > -1 || dp[i - 1][j][k - 1][1] > -1)){
					dp[i][j][k][0] = arr[i] + w;
					dp[i][j][k][1] = arr[i] + 2 * w ;
				}
				if(dp[i - 1][j][k][0] > arr[i]) dp[i][j][k][0] = max(dp[i - 1][j][k][0], dp[i][j][k][0]);
				if(dp[i - 1][j][k][1] > arr[i]) dp[i][j][k][1] = max(dp[i - 1][j][k][1], dp[i][j][k][1]);
				// cout << dp[i][j][k][0] << ' ' << dp[i][j][k][1] << " . " << j << ' ' << k << " | "; 
			}

			// cout << '\n';
		}
		// cout << '\n';
	}
	// cout << '\n';
	return (dp[n][p][q][0] > -1 || dp[n][p][q][1] > -1); 
}


int main(){
	cin >> n >> p >> q;
	for(int i = 1; i <= n; i++) cin >> arr[i];
	if(p + q >= n){
		cout << 1;
		return 0;
	}
	sort(arr+1, arr+n+1);
	int l = 1, h = MX, ans = MX;
	while(l <= h){
		int mid = ((l+h)>>1);
		if(check(mid)){
			ans = min(ans, mid);
			h = mid - 1;
		}else
			l = mid + 1;
	}
	cout << ans;

	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -