#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int 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 = 1e8;
vector<vector<map<int,double long>>>dp(n + 1,vector<map<int,double long>>(k + 1));
function<double long(int,int,double long)>solve = [&](int i,int j,double long p){
if (i == n){
if (j == k)return (double long)0.0;
return mxn;
}
if (j == k){
return (double long)0.0;
}
if (dp[i][j][p])return dp[i][j][p];
double long ans = solve(i + 1,j,p);
ans = min(ans,solve(i + 1,j + 1,p) + (double long)(arr[i].first / p));
if (arr[i].second!=-1){
ans = min(ans,solve(i + 1,j + 1,p + 1) + (double long)(arr[i].second / p));
}
return dp[i][j][p] = ans;
};
cout<<fixed<<setprecision(15)<<solve(0,0,1)<<'\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 |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
4 ms |
3536 KB |
Output is correct |
6 |
Correct |
11 ms |
7676 KB |
Output is correct |
7 |
Correct |
19 ms |
13652 KB |
Output is correct |
8 |
Correct |
24 ms |
18392 KB |
Output is correct |
9 |
Correct |
27 ms |
21952 KB |
Output is correct |
10 |
Correct |
24 ms |
17620 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 |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
4 ms |
3536 KB |
Output is correct |
6 |
Correct |
11 ms |
7676 KB |
Output is correct |
7 |
Correct |
19 ms |
13652 KB |
Output is correct |
8 |
Correct |
24 ms |
18392 KB |
Output is correct |
9 |
Correct |
27 ms |
21952 KB |
Output is correct |
10 |
Correct |
24 ms |
17620 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1997 ms |
359072 KB |
Output is correct |
13 |
Correct |
1883 ms |
359292 KB |
Output is correct |
14 |
Correct |
1341 ms |
322496 KB |
Output is correct |
15 |
Execution timed out |
2602 ms |
469000 KB |
Time limit exceeded |
16 |
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 |
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 |
Execution timed out |
2574 ms |
466564 KB |
Time limit exceeded |
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 |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
4 ms |
3536 KB |
Output is correct |
6 |
Correct |
11 ms |
7676 KB |
Output is correct |
7 |
Correct |
19 ms |
13652 KB |
Output is correct |
8 |
Correct |
24 ms |
18392 KB |
Output is correct |
9 |
Correct |
27 ms |
21952 KB |
Output is correct |
10 |
Correct |
24 ms |
17620 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1997 ms |
359072 KB |
Output is correct |
13 |
Correct |
1883 ms |
359292 KB |
Output is correct |
14 |
Correct |
1341 ms |
322496 KB |
Output is correct |
15 |
Execution timed out |
2602 ms |
469000 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |