#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define INF (LL)(9e18)
#define int LL
using namespace std;
using LL=long long;
using pii=pair<int,int>;
template<typename T>
void chmin(T &_a,const T &_b){
if(_a>_b) _a=_b;
}
const int MAXN=510;
double p[MAXN];
pii a[MAXN];
double dp[MAXN][MAXN][MAXN];
int32_t main(){
ios::sync_with_stdio(false);
cin.tie(0);
// OAO
int n,K; cin>>n>>K;
For(i,1,n) cin>>a[i].F>>a[i].S;
sort(a+1,a+n+1,[](pii &pa,pii &pb){
return pa.S<pb.S;
});
// For(i,1,n) cerr<<a[i].F<<" "<<a[i].S<<"\n";
p[0]=1;
For(i,1,n) p[i]=1.0/(i+1);
For(i,0,n) For(j,0,n) For(k,0,n) dp[i][j][k]=INF;
dp[0][0][0]=0;
double ans=INF;
For(nc,0,K){
For(i,1,n) For(j,0,min(i,K)) For(k,0,min(j,nc)){
dp[i][j][k]=dp[i-1][j][k];
if(j){
chmin(dp[i][j][k],dp[i-1][j-1][k]+a[i].F*p[nc]);
}
if(a[i].S!=-1 && k){
chmin(dp[i][j][k],dp[i-1][j-1][k-1]+a[i].S*p[k-1]);
}
}
// if(nc==3){
// For(i,1,n) For(j,0,K) For(k,0,nc){
// cerr<<dp[i][j][k]<<"\t\n"[k==nc];
// if(j==K && k==nc) cerr<<"\n";
// }
// }
// cerr<<nc<<" "<<dp[n][K][nc]<<"\n";
chmin(ans,dp[n][K][nc]);
}
cout<<fixed<<setprecision(15);
cout<<ans<<"\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
626 ms |
1004340 KB |
Output is correct |
6 |
Correct |
1901 ms |
1004348 KB |
Output is correct |
7 |
Execution timed out |
2652 ms |
1004284 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
626 ms |
1004340 KB |
Output is correct |
6 |
Correct |
1901 ms |
1004348 KB |
Output is correct |
7 |
Execution timed out |
2652 ms |
1004284 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
588 KB |
Output is correct |
2 |
Correct |
1 ms |
588 KB |
Output is correct |
3 |
Correct |
1 ms |
588 KB |
Output is correct |
4 |
Correct |
1 ms |
588 KB |
Output is correct |
5 |
Correct |
1 ms |
588 KB |
Output is correct |
6 |
Correct |
1 ms |
588 KB |
Output is correct |
7 |
Correct |
1 ms |
588 KB |
Output is correct |
8 |
Correct |
1 ms |
588 KB |
Output is correct |
9 |
Correct |
1 ms |
588 KB |
Output is correct |
10 |
Correct |
1 ms |
588 KB |
Output is correct |
11 |
Correct |
1 ms |
584 KB |
Output is correct |
12 |
Correct |
1 ms |
588 KB |
Output is correct |
13 |
Correct |
1 ms |
588 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
1 ms |
588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
588 KB |
Output is correct |
2 |
Correct |
1 ms |
588 KB |
Output is correct |
3 |
Correct |
1 ms |
588 KB |
Output is correct |
4 |
Correct |
1 ms |
588 KB |
Output is correct |
5 |
Correct |
1 ms |
588 KB |
Output is correct |
6 |
Correct |
1 ms |
588 KB |
Output is correct |
7 |
Correct |
1 ms |
588 KB |
Output is correct |
8 |
Correct |
1 ms |
588 KB |
Output is correct |
9 |
Correct |
1 ms |
588 KB |
Output is correct |
10 |
Correct |
1 ms |
588 KB |
Output is correct |
11 |
Correct |
1 ms |
584 KB |
Output is correct |
12 |
Correct |
1 ms |
588 KB |
Output is correct |
13 |
Correct |
1 ms |
588 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
1 ms |
588 KB |
Output is correct |
16 |
Correct |
1 ms |
2124 KB |
Output is correct |
17 |
Correct |
2 ms |
2124 KB |
Output is correct |
18 |
Correct |
1 ms |
2116 KB |
Output is correct |
19 |
Correct |
1 ms |
2124 KB |
Output is correct |
20 |
Correct |
1 ms |
2124 KB |
Output is correct |
21 |
Correct |
2 ms |
2124 KB |
Output is correct |
22 |
Correct |
1 ms |
2124 KB |
Output is correct |
23 |
Correct |
1 ms |
2124 KB |
Output is correct |
24 |
Correct |
2 ms |
2132 KB |
Output is correct |
25 |
Correct |
1 ms |
2124 KB |
Output is correct |
26 |
Correct |
1 ms |
2124 KB |
Output is correct |
27 |
Correct |
1 ms |
2124 KB |
Output is correct |
28 |
Correct |
1 ms |
2108 KB |
Output is correct |
29 |
Correct |
1 ms |
2124 KB |
Output is correct |
30 |
Correct |
1 ms |
2124 KB |
Output is correct |
31 |
Correct |
1 ms |
2124 KB |
Output is correct |
32 |
Correct |
2 ms |
2124 KB |
Output is correct |
33 |
Correct |
1 ms |
2124 KB |
Output is correct |
34 |
Correct |
2 ms |
2124 KB |
Output is correct |
35 |
Correct |
1 ms |
2124 KB |
Output is correct |
36 |
Correct |
1 ms |
2124 KB |
Output is correct |
37 |
Correct |
1 ms |
2124 KB |
Output is correct |
38 |
Correct |
2 ms |
2124 KB |
Output is correct |
39 |
Correct |
2 ms |
2124 KB |
Output is correct |
40 |
Correct |
1 ms |
2096 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
588 KB |
Output is correct |
2 |
Correct |
1 ms |
588 KB |
Output is correct |
3 |
Correct |
1 ms |
588 KB |
Output is correct |
4 |
Correct |
1 ms |
588 KB |
Output is correct |
5 |
Correct |
1 ms |
588 KB |
Output is correct |
6 |
Correct |
1 ms |
588 KB |
Output is correct |
7 |
Correct |
1 ms |
588 KB |
Output is correct |
8 |
Correct |
1 ms |
588 KB |
Output is correct |
9 |
Correct |
1 ms |
588 KB |
Output is correct |
10 |
Correct |
1 ms |
588 KB |
Output is correct |
11 |
Correct |
1 ms |
584 KB |
Output is correct |
12 |
Correct |
1 ms |
588 KB |
Output is correct |
13 |
Correct |
1 ms |
588 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
1 ms |
588 KB |
Output is correct |
16 |
Correct |
1 ms |
2124 KB |
Output is correct |
17 |
Correct |
2 ms |
2124 KB |
Output is correct |
18 |
Correct |
1 ms |
2116 KB |
Output is correct |
19 |
Correct |
1 ms |
2124 KB |
Output is correct |
20 |
Correct |
1 ms |
2124 KB |
Output is correct |
21 |
Correct |
2 ms |
2124 KB |
Output is correct |
22 |
Correct |
1 ms |
2124 KB |
Output is correct |
23 |
Correct |
1 ms |
2124 KB |
Output is correct |
24 |
Correct |
2 ms |
2132 KB |
Output is correct |
25 |
Correct |
1 ms |
2124 KB |
Output is correct |
26 |
Correct |
1 ms |
2124 KB |
Output is correct |
27 |
Correct |
1 ms |
2124 KB |
Output is correct |
28 |
Correct |
1 ms |
2108 KB |
Output is correct |
29 |
Correct |
1 ms |
2124 KB |
Output is correct |
30 |
Correct |
1 ms |
2124 KB |
Output is correct |
31 |
Correct |
1 ms |
2124 KB |
Output is correct |
32 |
Correct |
2 ms |
2124 KB |
Output is correct |
33 |
Correct |
1 ms |
2124 KB |
Output is correct |
34 |
Correct |
2 ms |
2124 KB |
Output is correct |
35 |
Correct |
1 ms |
2124 KB |
Output is correct |
36 |
Correct |
1 ms |
2124 KB |
Output is correct |
37 |
Correct |
1 ms |
2124 KB |
Output is correct |
38 |
Correct |
2 ms |
2124 KB |
Output is correct |
39 |
Correct |
2 ms |
2124 KB |
Output is correct |
40 |
Correct |
1 ms |
2096 KB |
Output is correct |
41 |
Correct |
19 ms |
41432 KB |
Output is correct |
42 |
Correct |
19 ms |
41404 KB |
Output is correct |
43 |
Correct |
26 ms |
41420 KB |
Output is correct |
44 |
Correct |
24 ms |
41416 KB |
Output is correct |
45 |
Correct |
42 ms |
41408 KB |
Output is correct |
46 |
Correct |
41 ms |
41396 KB |
Output is correct |
47 |
Correct |
48 ms |
41420 KB |
Output is correct |
48 |
Correct |
43 ms |
41348 KB |
Output is correct |
49 |
Correct |
59 ms |
41348 KB |
Output is correct |
50 |
Correct |
75 ms |
41436 KB |
Output is correct |
51 |
Correct |
83 ms |
41432 KB |
Output is correct |
52 |
Correct |
86 ms |
41440 KB |
Output is correct |
53 |
Correct |
48 ms |
41496 KB |
Output is correct |
54 |
Correct |
46 ms |
41360 KB |
Output is correct |
55 |
Correct |
59 ms |
41420 KB |
Output is correct |
56 |
Correct |
60 ms |
41420 KB |
Output is correct |
57 |
Correct |
52 ms |
41412 KB |
Output is correct |
58 |
Correct |
54 ms |
41432 KB |
Output is correct |
59 |
Correct |
43 ms |
41432 KB |
Output is correct |
60 |
Correct |
55 ms |
41440 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2656 ms |
1004292 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
332 KB |
Output is correct |
3 |
Correct |
0 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
626 ms |
1004340 KB |
Output is correct |
6 |
Correct |
1901 ms |
1004348 KB |
Output is correct |
7 |
Execution timed out |
2652 ms |
1004284 KB |
Time limit exceeded |
8 |
Halted |
0 ms |
0 KB |
- |