#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<limits.h>
#include <cassert>
#include<cmath>
#include<set>
#include<algorithm>
#include <iomanip>
#include<numeric> //gcd(a,b)
#include<bitset>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define ppii pair<pii,int>
#define vi vector<int>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define F(n) for(int i=0;i<n;i++)
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-loops")
using namespace std;
#define int long long
#define double long double
const int mod=998244353,mxn=2e5+5,lg=30,inf=1e18,minf=-1e18,Mxn=100000;
bool use[mxn+10];
double dp[505][505][505];
int32_t main(){
fastio
int n,k;cin>>n>>k;
double ans=inf;
vector<ppii>v(n);
for(int i=0;i<n;i++)cin>>v[i].f.f>>v[i].f.s,v[i].s=i;
vector<pii>b;
for(int i=0;i<n;i++)if(v[i].f.s!=-1)b.pb({v[i].f.s,i});
b.pb({minf,69});
for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)for(int g=0;g<=n;g++)dp[i][j][g]=inf;
sort(all(b));
for(int i=0;i<n;i++)if(v[i].f.s==-1)b.pb({v[i].f.s,i});
dp[0][1][0]=0;
for(int i=1;i<=n;i++){
for(int j=1;j<=n;j++){
for(int g=1;g<=k;g++){
dp[i][j][g]=dp[i-1][j][g];
if(dp[i-1][j][g-1]!=inf)dp[i][j][g]=min(dp[i][j][g],dp[i-1][j][g-1]+(v[b[i].s].f.f*1.0)/j);
if(b[i].f!=-1&&j>1&&dp[i-1][j-1][g-1]!=inf)dp[i][j][g]=min(dp[i-1][j-1][g-1]+((b[i].f)*1.0/(j-1)),dp[i][j][g]);
if(g==k)ans=min(ans,dp[i][j][g]);
}
}
}
cout<<setprecision(12);
cout<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Incorrect |
1 ms |
6492 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Incorrect |
1 ms |
6492 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
14684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
14684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
14684 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
504 ms |
1048576 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
1 ms |
4444 KB |
Output is correct |
3 |
Incorrect |
1 ms |
6492 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |