#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<double, double> pll;
#define fastio ios::sync_with_stdio(false), cin.tie(0)
#pragma GCC optimize("Ofast")
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lowbit(x) x&-x
const int maxn = 2e5 + 5;
const double INF = 1e18;
int main(void){
fastio;
int n, k;
cin>>n>>k;
vector<pll> a(n);
for(int i = 0; i < n; i++){
cin>>a[i].f>>a[i].s;
if(a[i].s == -1) a[i].s = INF;
}
sort(a.begin(), a.end(), [&](pll a, pll b){ return a.s < b.s || (a.s == b.s && a.f < b.f);});
vector<vector<double>> dp(n + 5, vector<double>(n + 5, INF));
dp[0][1] = 0;
for(int i = 0; i < n; i++){
auto [v0, v1] = a[i];
cout<<v0<<" "<<v1<<"\n";
for(int j = k - 1; j >= 0; j--){
for(int cnt = 1; cnt <= k; cnt++){
dp[j + 1][cnt] = min(dp[j + 1][cnt], dp[j][cnt] + v0 / cnt);
dp[j + 1][cnt + 1] = min(dp[j + 1][cnt + 1], dp[j][cnt] + v1 / cnt);
}
}
}
double ans = INF;
for(int cnt = 1; cnt <= k; cnt++){
ans = min(ans, dp[k][cnt]);
}
cout<<fixed<<setprecision(5)<<ans<<"\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
576 ms |
2644 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |