# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1066615 |
2024-08-20T03:22:04 Z |
Luvidi |
Watching (JOI13_watching) |
C++17 |
|
104 ms |
16120 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fs first
#define sc second
#define pb push_back
void solve() {
int n,p,q;
cin>>n>>p>>q;
int a[n+1];
for(int i=1;i<=n;i++)cin>>a[i];
sort(a+1,a+n+1);
p=min(p,n);
q=min(q,n);
int l=1,r=1e9;
while(l<r){
int m=(l+r)/2;
int dp[n+1][q+1];
for(int i=0;i<=q;i++)dp[0][i]=0;
int idx1=1,idx2=1;
for(int i=1;i<=n;i++){
while(a[i]-a[idx1]+1>m)idx1++;
while(a[i]-a[idx2]+1>2*m)idx2++;
for(int j=0;j<=q;j++){
dp[i][j]=dp[idx1-1][j]+1;
if(j){
dp[i][j]=min(dp[i][j],dp[idx2-1][j-1]);
}
}
}
if(dp[n][q]<=p)r=m;
else l=m+1;
}
cout<<l;
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
456 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 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 |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
600 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
496 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
71 ms |
12124 KB |
Output is correct |
4 |
Correct |
5 ms |
1088 KB |
Output is correct |
5 |
Correct |
104 ms |
16120 KB |
Output is correct |
6 |
Correct |
97 ms |
15960 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
70 ms |
6364 KB |
Output is correct |
9 |
Correct |
9 ms |
1372 KB |
Output is correct |
10 |
Correct |
5 ms |
1116 KB |
Output is correct |
11 |
Correct |
86 ms |
15340 KB |
Output is correct |
12 |
Correct |
50 ms |
8028 KB |
Output is correct |
13 |
Correct |
3 ms |
604 KB |
Output is correct |
14 |
Correct |
1 ms |
472 KB |
Output is correct |
15 |
Correct |
2 ms |
604 KB |
Output is correct |