# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
564901 |
2022-05-19T23:25:35 Z |
SSRS |
Watching (JOI13_watching) |
C++14 |
|
849 ms |
16116 KB |
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000;
int main(){
int N, P, Q;
cin >> N >> P >> Q;
P = min(P, N);
Q = min(Q, N);
vector<int> A(N);
for (int i = 0; i < N; i++){
cin >> A[i];
}
sort(A.begin(), A.end());
int tv = 500000000, fv = 0;
while (tv - fv > 1){
int mid = (tv + fv) / 2;
vector<int> R1(N), R2(N);
for (int i = 0; i < N; i++){
R1[i] = lower_bound(A.begin(), A.end(), A[i] + mid) - A.begin();
R2[i] = lower_bound(A.begin(), A.end(), A[i] + mid * 2) - A.begin();
}
vector<vector<int>> dp(N + 1, vector<int>(P + 1, INF));
dp[0][0] = 0;
for (int i = 0; i < N; i++){
for (int j = 0; j <= min(P, i); j++){
if (j < P){
dp[R1[i]][j + 1] = min(dp[R1[i]][j + 1], dp[i][j]);
}
dp[R2[i]][j] = min(dp[R2[i]][j], dp[i][j] + 1);
}
}
bool ok = false;
for (int i = 0; i <= P; i++){
if (dp[N][i] <= Q){
ok = true;
}
}
if (ok){
tv = mid;
} else {
fv = mid;
}
}
cout << tv << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
3 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
2 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
756 ms |
12160 KB |
Output is correct |
4 |
Correct |
792 ms |
16116 KB |
Output is correct |
5 |
Correct |
56 ms |
1028 KB |
Output is correct |
6 |
Correct |
787 ms |
16084 KB |
Output is correct |
7 |
Correct |
16 ms |
468 KB |
Output is correct |
8 |
Correct |
96 ms |
1396 KB |
Output is correct |
9 |
Correct |
473 ms |
6352 KB |
Output is correct |
10 |
Correct |
849 ms |
15440 KB |
Output is correct |
11 |
Correct |
67 ms |
1204 KB |
Output is correct |
12 |
Correct |
614 ms |
8140 KB |
Output is correct |
13 |
Correct |
16 ms |
468 KB |
Output is correct |
14 |
Correct |
21 ms |
468 KB |
Output is correct |
15 |
Correct |
19 ms |
596 KB |
Output is correct |