#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){
y = 1e7;
}
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;
});
for (auto x:temp)arr.push_back(x);
double long mxn = 1e15;
vector<vector<double long>>dp(n + 1,vector<double long>(n + 2,mxn));
dp[0][1] = 0.0;
for (int i = 0;i<n;++i){
vector<vector<double long>>cur_dp(n + 1,vector<double long>(n + 2,mxn));
for (int j = 0;j<=i;++j){
for (int p = 1;p <= i + 1;++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)),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)));
}
}
swap(cur_dp,dp);
}
double long ans = mxn;
for (int i = 0;i<=n + 1;++i){
ans = min(ans,dp[k][i]);
}
cout<<fixed<<setprecision(15)<<ans<<'\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
1621 ms |
8560 KB |
Output is correct |
6 |
Correct |
1636 ms |
8340 KB |
Output is correct |
7 |
Correct |
1618 ms |
8360 KB |
Output is correct |
8 |
Correct |
1598 ms |
8368 KB |
Output is correct |
9 |
Correct |
1669 ms |
8428 KB |
Output is correct |
10 |
Correct |
1588 ms |
8388 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
1621 ms |
8560 KB |
Output is correct |
6 |
Correct |
1636 ms |
8340 KB |
Output is correct |
7 |
Correct |
1618 ms |
8360 KB |
Output is correct |
8 |
Correct |
1598 ms |
8368 KB |
Output is correct |
9 |
Correct |
1669 ms |
8428 KB |
Output is correct |
10 |
Correct |
1588 ms |
8388 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1603 ms |
8464 KB |
Output is correct |
13 |
Correct |
1555 ms |
8480 KB |
Output is correct |
14 |
Correct |
1634 ms |
8384 KB |
Output is correct |
15 |
Correct |
1595 ms |
8380 KB |
Output is correct |
16 |
Correct |
1548 ms |
8504 KB |
Output is correct |
17 |
Correct |
1616 ms |
8608 KB |
Output is correct |
18 |
Correct |
1590 ms |
8396 KB |
Output is correct |
19 |
Correct |
1587 ms |
8324 KB |
Output is correct |
20 |
Correct |
1624 ms |
8564 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
0 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 |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
0 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 |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
0 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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1605 ms |
8612 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1621 ms |
8560 KB |
Output is correct |
6 |
Correct |
1636 ms |
8340 KB |
Output is correct |
7 |
Correct |
1618 ms |
8360 KB |
Output is correct |
8 |
Correct |
1598 ms |
8368 KB |
Output is correct |
9 |
Correct |
1669 ms |
8428 KB |
Output is correct |
10 |
Correct |
1588 ms |
8388 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1603 ms |
8464 KB |
Output is correct |
13 |
Correct |
1555 ms |
8480 KB |
Output is correct |
14 |
Correct |
1634 ms |
8384 KB |
Output is correct |
15 |
Correct |
1595 ms |
8380 KB |
Output is correct |
16 |
Correct |
1548 ms |
8504 KB |
Output is correct |
17 |
Correct |
1616 ms |
8608 KB |
Output is correct |
18 |
Correct |
1590 ms |
8396 KB |
Output is correct |
19 |
Correct |
1587 ms |
8324 KB |
Output is correct |
20 |
Correct |
1624 ms |
8564 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 |
0 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 |
- |