Submission #1157403

#TimeUsernameProblemLanguageResultExecution timeMemory
1157403zhasynWatching (JOI13_watching)C++20
100 / 100
135 ms16896 KiB
#include <bits/stdc++.h> #define pb push_back #define pf push_front using namespace std; #define F first #define S second typedef long long ll; #define pii pair <int, int> #define pll pair <ll, ll> typedef long double ld; const ll N = 2000 + 100, M = 4096 + 10, len = 21, inf = 1e18; const ll mod = 1e9 + 7; ll um(ll a, ll b){ return (1LL * a * b) % mod; } ll subr(ll a, ll b){ return ((1LL * a - b) % mod + mod) % mod; } int pos[N], n, a, b, cur[N][N]; bool calc(int x){ cur[0][a] = b; //cout << x << endl; for(int i = 0; i < n; i++){ int lx = n, lxx = n; for(int j = i; j < n; j++){ if(pos[j] > pos[i] + x - 1) lx = min(j, lx); if(pos[j] > pos[i] + 2 * x - 1){ lxx = j; break; } } //cout << i << " "<< lx << " " << lxx << endl; for(int j = 0; j <= a; j++){ if(cur[i][j] > 1) cur[lxx][j] = max(cur[lxx][j], cur[i][j] - 1); if(j > 0) cur[lx][j - 1] = max(cur[lx][j - 1], cur[i][j]); } for(int j = 0; j <= a; j++){ cur[i][j] = 0; } } bool can = false; for(int i = 0; i <= a; i++){ if(cur[n][i] >= 1) can = true; cur[n][i] = 0; } return can; } int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n >> a >> b; b++; if(a + b - 1 >= n){ cout << 1; return 0; } for(int i = 0; i < n; i++){ cin >> pos[i]; } sort(pos, pos + n); int l = 0, r = 1e9; while(r - l > 1){ int mid = (r + l) / 2; if(calc(mid)) r = mid; else l = mid; } cout << r; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...