# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
987280 |
2024-05-22T13:40:14 Z |
aykhn |
Watching (JOI13_watching) |
C++17 |
|
604 ms |
30316 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inf 0x3F3F3F3F
const int MXN = 2e3 + 5;
int n, p, q;
int a[MXN];
int dp[MXN][MXN];
int need(int val)
{
for (int i = 0; i <= p; i++)
{
int k1 = 0, k2 = 0;
for (int j = 1; j <= n; j++)
{
dp[i][j] = inf;
while (k1 + 1 <= n && a[k1 + 1] <= a[j] - val) k1++;
while (k2 + 1 <= n && a[k2 + 1] <= a[j] - 2 * val) k2++;
dp[i][j] = dp[i][k2] + 1;
if (i) dp[i][j] = min(dp[i][j], dp[i - 1][k1]);
}
}
return dp[p][n];
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> n >> p >> q;
if (p >= n || q >= n)
{
cout << 1 << '\n';
return 0;
}
p = min(p, n), q = min(q, n);
for (int i = 1; i <= n; i++) cin >> a[i];
sort(a + 1, a + n + 1);
int l = 1, r = 1e9;
while (l < r)
{
int mid = (l + r) >> 1;
if (need(mid) > q) l = mid + 1;
else r = mid;
}
cout << l << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
2396 KB |
Output is correct |
10 |
Correct |
2 ms |
2396 KB |
Output is correct |
11 |
Correct |
2 ms |
604 KB |
Output is correct |
12 |
Correct |
2 ms |
604 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
484 ms |
24036 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
6 ms |
600 KB |
Output is correct |
8 |
Correct |
43 ms |
2396 KB |
Output is correct |
9 |
Correct |
260 ms |
12124 KB |
Output is correct |
10 |
Correct |
604 ms |
30316 KB |
Output is correct |
11 |
Correct |
29 ms |
1880 KB |
Output is correct |
12 |
Correct |
308 ms |
16040 KB |
Output is correct |
13 |
Correct |
4 ms |
600 KB |
Output is correct |
14 |
Correct |
5 ms |
600 KB |
Output is correct |
15 |
Correct |
5 ms |
604 KB |
Output is correct |