Submission #923282

# Submission time Handle Problem Language Result Execution time Memory
923282 2024-02-07T04:59:08 Z oblantis Watching (JOI13_watching) C++17
0 / 100
1 ms 348 KB
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(v) v.begin(), v.end()
#define pb push_back
#define ss second
#define ff first
#define vt vector
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int inf = 1e9;
const int mod = 1e9+7;
const int maxn = 1e6 + 1;

void solve() {
	int n, p, q;
	cin >> n >> p >> q;
	if(p + q >= n){
		cout << 1;
		return;
	}
	int a[n + 1], dp[n + 1][q + 1];
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	int l = 0, r = inf;
	while(l + 1 < r){
		int w = l + (r - l) / 2;
		for(int i = 0; i <= q; i++)dp[0][i] = 0;
		for(int i = 1, xl = 1, lx = 1; i <= n; i++){
			while(a[i] - a[xl] >= w * 2){
				xl++;
			}
			while(a[i] - a[lx] >= w)lx++;
			dp[i][0] = dp[lx - 1][0] + 1;
			for(int j = 1; j <= q; j++){
				dp[i][j] = min(dp[xl - 1][j - 1], dp[lx - 1][j] + 1);
			}
		}
		if(dp[n][q] <= p)r = w;
		else l = w;
	}
	cout << r;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int times = 1;
	//cin >> times;
	for(int i = 1; i <= times; i++) {
		solve();
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -