Submission #1001720

#TimeUsernameProblemLanguageResultExecution timeMemory
1001720HasanV11010238Watching (JOI13_watching)C++17
0 / 100
72 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define INF 1000000000 int n, p, q; vector<int> a; int main(){ cin>>n>>p>>q; a.assign(n + 1, 0); for (int i = 1; i <= n; i++){ cin>>a[i]; } sort(a.begin(), a.end()); if (n <= p + 1){ cout<<1; return 0; } ll dp[n + 1][q + 1][p + 1]; for (int i = 0; i <= n; i++){ for (int j = 0; j <= p; j++){ for (int k = 0; k <= q; k++){ dp[i][j][k] = 0; } } } for (int i = 1; i <= n; i++){ for (int j = 0; j <= p; j++){ for (int k = 0; k <= q; k++){ dp[i][j][k] = INF; for (int l = 0; l <= i; l++){ if (l == i){ for (int m = 0; m <= l; m++){ if (j != 0){ dp[i][j][k] = min(dp[i][j][k], max(1ll, dp[i][j - 1][k])); } if (k != 0){ dp[i][j][k] = min(dp[i][j][k], max(1ll, dp[i][j][k - 1])); } } } ll dist = ceil((double)(a[i] - a[l] + 1) / (double)2); ll bi = ceil((double)dist / (double)2); if (j != 0){ dp[i][j][k] = min(max(dp[l][j - 1][k], dist), dp[i][j][k]); } if (k != 0){ dp[i][j][k] = min(max(dp[l][j][k - 1], bi), dp[i][j][k]); } } } } } cout<<dp[n][p][q]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...