#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
double long n,k;cin>>n>>k;
vector<pair<double long,double long>>arr,temp;
for (int i = 0;i<n;++i){
double long x,y;cin>>x>>y;
if (y == -1){
temp.push_back({x,y});
}
else{
arr.push_back({x,y});
}
}
sort(arr.begin(),arr.end(),[&](auto x,auto y){
if (x.second == y.second)return x.first < y.first;
return x.second < y.second;
});
sort(temp.begin(),temp.end(),[&](auto x,auto y){
return x.first < y.first;
});
for (auto x:temp)arr.push_back(x);
double long mxn = 1e15;
vector<vector<double long>>dp(n + 1,vector<double long>(n + 1,mxn));
dp[0][0] = 0.0;
for (int i = 0;i<n;++i){
vector<vector<double long>>cur_dp(n + 1,vector<double long>(n + 1,mxn));
for (int j = 0;j<=i;++j){
for (int p = 0;p <= j;++p){
cur_dp[j][p] = min(cur_dp[j][p],dp[j][p]);
cur_dp[j + 1][p + 1] = min(cur_dp[j + 1][p + 1],dp[j + 1][p + 1]);
cur_dp[j + 1][p] = min(cur_dp[j + 1][p],dp[j + 1][p]);
if (arr[i].second!=-1){
cur_dp[j + 1][p + 1] = min(dp[j][p] + (double long)(arr[i].second / (p + 1)),cur_dp[j + 1][p + 1]);
}
cur_dp[j + 1][p] = min(cur_dp[j + 1][p],dp[j][p] + (double long)(arr[i].first / (p + 1)));
}
}
swap(cur_dp,dp);
}
double long ans = mxn;
for (int i = 0;i<=n;++i){
ans = min(ans,dp[k][i]);
}
cout<<fixed<<setprecision(15)<<ans<<'\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
893 ms |
8396 KB |
Output is correct |
6 |
Correct |
908 ms |
8396 KB |
Output is correct |
7 |
Correct |
943 ms |
8320 KB |
Output is correct |
8 |
Correct |
907 ms |
8520 KB |
Output is correct |
9 |
Correct |
940 ms |
8404 KB |
Output is correct |
10 |
Correct |
933 ms |
8600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
893 ms |
8396 KB |
Output is correct |
6 |
Correct |
908 ms |
8396 KB |
Output is correct |
7 |
Correct |
943 ms |
8320 KB |
Output is correct |
8 |
Correct |
907 ms |
8520 KB |
Output is correct |
9 |
Correct |
940 ms |
8404 KB |
Output is correct |
10 |
Correct |
933 ms |
8600 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
981 ms |
8416 KB |
Output is correct |
13 |
Correct |
942 ms |
8376 KB |
Output is correct |
14 |
Correct |
924 ms |
8608 KB |
Output is correct |
15 |
Correct |
1004 ms |
8544 KB |
Output is correct |
16 |
Correct |
933 ms |
8484 KB |
Output is correct |
17 |
Correct |
916 ms |
8392 KB |
Output is correct |
18 |
Correct |
973 ms |
8416 KB |
Output is correct |
19 |
Correct |
957 ms |
8488 KB |
Output is correct |
20 |
Correct |
899 ms |
8396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
980 ms |
8508 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
893 ms |
8396 KB |
Output is correct |
6 |
Correct |
908 ms |
8396 KB |
Output is correct |
7 |
Correct |
943 ms |
8320 KB |
Output is correct |
8 |
Correct |
907 ms |
8520 KB |
Output is correct |
9 |
Correct |
940 ms |
8404 KB |
Output is correct |
10 |
Correct |
933 ms |
8600 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
981 ms |
8416 KB |
Output is correct |
13 |
Correct |
942 ms |
8376 KB |
Output is correct |
14 |
Correct |
924 ms |
8608 KB |
Output is correct |
15 |
Correct |
1004 ms |
8544 KB |
Output is correct |
16 |
Correct |
933 ms |
8484 KB |
Output is correct |
17 |
Correct |
916 ms |
8392 KB |
Output is correct |
18 |
Correct |
973 ms |
8416 KB |
Output is correct |
19 |
Correct |
957 ms |
8488 KB |
Output is correct |
20 |
Correct |
899 ms |
8396 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
0 ms |
212 KB |
Output is correct |
24 |
Correct |
0 ms |
212 KB |
Output is correct |
25 |
Correct |
0 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
212 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |