Submission #274728

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
2747282020-08-19 14:46:16bicsi구경하기 (JOI13_watching)C++14
100 / 100
197 ms15276 KiB
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, p, q; cin >> n >> p >> q;
if (p + q >= n) {
cout << 1 << endl;
return 0;
}
vector<int> a(n);
for (int i = 0; i < n; ++i)
cin >> a[i];
sort(a.begin(), a.end());
auto ok = [&](int w) -> bool {
int ps = 0, pl = 0;
vector<vector<int>> dp(n + 1, vector<int>(p + 1, n + 1));
fill(dp[0].begin(), dp[0].end(), 0);
for (int i = 0; i < n; ++i) {
while (a[ps] <= a[i] - w) ++ps;
while (a[pl] <= a[i] - 2 * w) ++pl;
for (int j = 0; j <= p; ++j) {
if (j > 0) dp[i + 1][j] = min(dp[i + 1][j], dp[ps][j - 1]);
dp[i + 1][j] = min(dp[i + 1][j], dp[pl][j] + 1);
}
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...