#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<float.h>
#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=1e9,minf=-1e9,Mxn=100000;
//bool use[mxn+10];
double dp[600][600];
int32_t main(){
fastio
int n,k;cin>>n>>k;
double ans=inf;
vector<pii>v(n);
for(int i=0;i<n;i++){
cin>>v[i].f>>v[i].s;
v[i].s=(v[i].s==-1)?inf:v[i].s;
swap(v[i].s,v[i].f);
}
sort(all(v));
vector<vector<int>>sum(600,vector<int>(600,inf));
for(int i=0;i<=n;i++)sum[i][0]=0;
for(int i=n-1;i>=0;i--)for(int j=k;j>=1;j--)sum[i][j]=min(sum[i+1][j],sum[i+1][j-1]+v[i].s);
ans=min(ans,(double)sum[0][k]);
for(int use=1;use<=k;use++){
for(int i=0;i<=n;i++)for(int j=0;j<=n;j++)dp[i][j]=inf;
dp[0][0]=0;
for(int j=0;j<k;j++){
for(int g=0;g<use;g++){
dp[j+1][g]=min(dp[j][g]+(v[j].s*1.0/use),dp[j+1][g]);
if(v[j].f!=inf)dp[j+1][g+1]=min(dp[j+1][g+1],dp[j][g]+(v[j].f*1.0/(g+1)));
}
ans=min(ans,dp[j+1][use-1]+sum[j+1][k-j-1]*1.0/use);
}
}
cout<<setprecision(12);
cout<<ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3164 KB |
Output is correct |
2 |
Correct |
1 ms |
3164 KB |
Output is correct |
3 |
Correct |
1 ms |
3164 KB |
Output is correct |
4 |
Correct |
1 ms |
3176 KB |
Output is correct |
5 |
Correct |
52 ms |
7768 KB |
Output is correct |
6 |
Correct |
130 ms |
7768 KB |
Output is correct |
7 |
Correct |
276 ms |
7996 KB |
Output is correct |
8 |
Correct |
450 ms |
7772 KB |
Output is correct |
9 |
Correct |
680 ms |
8000 KB |
Output is correct |
10 |
Correct |
419 ms |
8016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3164 KB |
Output is correct |
2 |
Correct |
1 ms |
3164 KB |
Output is correct |
3 |
Correct |
1 ms |
3164 KB |
Output is correct |
4 |
Correct |
1 ms |
3176 KB |
Output is correct |
5 |
Correct |
52 ms |
7768 KB |
Output is correct |
6 |
Correct |
130 ms |
7768 KB |
Output is correct |
7 |
Correct |
276 ms |
7996 KB |
Output is correct |
8 |
Correct |
450 ms |
7772 KB |
Output is correct |
9 |
Correct |
680 ms |
8000 KB |
Output is correct |
10 |
Correct |
419 ms |
8016 KB |
Output is correct |
11 |
Correct |
1 ms |
3164 KB |
Output is correct |
12 |
Correct |
163 ms |
7772 KB |
Output is correct |
13 |
Correct |
164 ms |
7996 KB |
Output is correct |
14 |
Correct |
165 ms |
8012 KB |
Output is correct |
15 |
Correct |
488 ms |
7772 KB |
Output is correct |
16 |
Correct |
485 ms |
8004 KB |
Output is correct |
17 |
Correct |
445 ms |
8004 KB |
Output is correct |
18 |
Correct |
896 ms |
8028 KB |
Output is correct |
19 |
Correct |
833 ms |
7772 KB |
Output is correct |
20 |
Correct |
739 ms |
8000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3164 KB |
Output is correct |
2 |
Correct |
1 ms |
3164 KB |
Output is correct |
3 |
Correct |
1 ms |
3160 KB |
Output is correct |
4 |
Correct |
1 ms |
3164 KB |
Output is correct |
5 |
Correct |
2 ms |
3164 KB |
Output is correct |
6 |
Correct |
1 ms |
3164 KB |
Output is correct |
7 |
Correct |
1 ms |
3164 KB |
Output is correct |
8 |
Correct |
1 ms |
3164 KB |
Output is correct |
9 |
Correct |
1 ms |
3120 KB |
Output is correct |
10 |
Correct |
1 ms |
3164 KB |
Output is correct |
11 |
Correct |
1 ms |
3164 KB |
Output is correct |
12 |
Correct |
1 ms |
3164 KB |
Output is correct |
13 |
Correct |
1 ms |
3164 KB |
Output is correct |
14 |
Correct |
1 ms |
3160 KB |
Output is correct |
15 |
Correct |
1 ms |
3164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3164 KB |
Output is correct |
2 |
Correct |
1 ms |
3164 KB |
Output is correct |
3 |
Correct |
1 ms |
3160 KB |
Output is correct |
4 |
Correct |
1 ms |
3164 KB |
Output is correct |
5 |
Correct |
2 ms |
3164 KB |
Output is correct |
6 |
Correct |
1 ms |
3164 KB |
Output is correct |
7 |
Correct |
1 ms |
3164 KB |
Output is correct |
8 |
Correct |
1 ms |
3164 KB |
Output is correct |
9 |
Correct |
1 ms |
3120 KB |
Output is correct |
10 |
Correct |
1 ms |
3164 KB |
Output is correct |
11 |
Correct |
1 ms |
3164 KB |
Output is correct |
12 |
Correct |
1 ms |
3164 KB |
Output is correct |
13 |
Correct |
1 ms |
3164 KB |
Output is correct |
14 |
Correct |
1 ms |
3160 KB |
Output is correct |
15 |
Correct |
1 ms |
3164 KB |
Output is correct |
16 |
Correct |
2 ms |
5212 KB |
Output is correct |
17 |
Correct |
2 ms |
5212 KB |
Output is correct |
18 |
Correct |
2 ms |
5212 KB |
Output is correct |
19 |
Correct |
2 ms |
5212 KB |
Output is correct |
20 |
Correct |
2 ms |
5212 KB |
Output is correct |
21 |
Correct |
2 ms |
5212 KB |
Output is correct |
22 |
Correct |
2 ms |
5212 KB |
Output is correct |
23 |
Correct |
2 ms |
5212 KB |
Output is correct |
24 |
Correct |
2 ms |
5212 KB |
Output is correct |
25 |
Correct |
2 ms |
5212 KB |
Output is correct |
26 |
Correct |
2 ms |
5212 KB |
Output is correct |
27 |
Correct |
1 ms |
5328 KB |
Output is correct |
28 |
Correct |
2 ms |
5464 KB |
Output is correct |
29 |
Correct |
2 ms |
5208 KB |
Output is correct |
30 |
Correct |
2 ms |
5316 KB |
Output is correct |
31 |
Correct |
2 ms |
5208 KB |
Output is correct |
32 |
Correct |
2 ms |
5212 KB |
Output is correct |
33 |
Correct |
2 ms |
5212 KB |
Output is correct |
34 |
Correct |
2 ms |
5212 KB |
Output is correct |
35 |
Correct |
2 ms |
5212 KB |
Output is correct |
36 |
Correct |
2 ms |
5212 KB |
Output is correct |
37 |
Correct |
2 ms |
5212 KB |
Output is correct |
38 |
Correct |
2 ms |
5212 KB |
Output is correct |
39 |
Correct |
2 ms |
5212 KB |
Output is correct |
40 |
Correct |
2 ms |
5212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3164 KB |
Output is correct |
2 |
Correct |
1 ms |
3164 KB |
Output is correct |
3 |
Correct |
1 ms |
3160 KB |
Output is correct |
4 |
Correct |
1 ms |
3164 KB |
Output is correct |
5 |
Correct |
2 ms |
3164 KB |
Output is correct |
6 |
Correct |
1 ms |
3164 KB |
Output is correct |
7 |
Correct |
1 ms |
3164 KB |
Output is correct |
8 |
Correct |
1 ms |
3164 KB |
Output is correct |
9 |
Correct |
1 ms |
3120 KB |
Output is correct |
10 |
Correct |
1 ms |
3164 KB |
Output is correct |
11 |
Correct |
1 ms |
3164 KB |
Output is correct |
12 |
Correct |
1 ms |
3164 KB |
Output is correct |
13 |
Correct |
1 ms |
3164 KB |
Output is correct |
14 |
Correct |
1 ms |
3160 KB |
Output is correct |
15 |
Correct |
1 ms |
3164 KB |
Output is correct |
16 |
Correct |
2 ms |
5212 KB |
Output is correct |
17 |
Correct |
2 ms |
5212 KB |
Output is correct |
18 |
Correct |
2 ms |
5212 KB |
Output is correct |
19 |
Correct |
2 ms |
5212 KB |
Output is correct |
20 |
Correct |
2 ms |
5212 KB |
Output is correct |
21 |
Correct |
2 ms |
5212 KB |
Output is correct |
22 |
Correct |
2 ms |
5212 KB |
Output is correct |
23 |
Correct |
2 ms |
5212 KB |
Output is correct |
24 |
Correct |
2 ms |
5212 KB |
Output is correct |
25 |
Correct |
2 ms |
5212 KB |
Output is correct |
26 |
Correct |
2 ms |
5212 KB |
Output is correct |
27 |
Correct |
1 ms |
5328 KB |
Output is correct |
28 |
Correct |
2 ms |
5464 KB |
Output is correct |
29 |
Correct |
2 ms |
5208 KB |
Output is correct |
30 |
Correct |
2 ms |
5316 KB |
Output is correct |
31 |
Correct |
2 ms |
5208 KB |
Output is correct |
32 |
Correct |
2 ms |
5212 KB |
Output is correct |
33 |
Correct |
2 ms |
5212 KB |
Output is correct |
34 |
Correct |
2 ms |
5212 KB |
Output is correct |
35 |
Correct |
2 ms |
5212 KB |
Output is correct |
36 |
Correct |
2 ms |
5212 KB |
Output is correct |
37 |
Correct |
2 ms |
5212 KB |
Output is correct |
38 |
Correct |
2 ms |
5212 KB |
Output is correct |
39 |
Correct |
2 ms |
5212 KB |
Output is correct |
40 |
Correct |
2 ms |
5212 KB |
Output is correct |
41 |
Correct |
3 ms |
5212 KB |
Output is correct |
42 |
Correct |
2 ms |
5212 KB |
Output is correct |
43 |
Correct |
3 ms |
5212 KB |
Output is correct |
44 |
Correct |
3 ms |
5212 KB |
Output is correct |
45 |
Correct |
4 ms |
5212 KB |
Output is correct |
46 |
Correct |
4 ms |
5212 KB |
Output is correct |
47 |
Correct |
5 ms |
5212 KB |
Output is correct |
48 |
Correct |
5 ms |
5216 KB |
Output is correct |
49 |
Correct |
7 ms |
5464 KB |
Output is correct |
50 |
Correct |
7 ms |
5208 KB |
Output is correct |
51 |
Correct |
9 ms |
5212 KB |
Output is correct |
52 |
Correct |
9 ms |
5212 KB |
Output is correct |
53 |
Correct |
5 ms |
5212 KB |
Output is correct |
54 |
Correct |
5 ms |
5328 KB |
Output is correct |
55 |
Correct |
5 ms |
5208 KB |
Output is correct |
56 |
Correct |
5 ms |
5212 KB |
Output is correct |
57 |
Correct |
5 ms |
5212 KB |
Output is correct |
58 |
Correct |
5 ms |
5328 KB |
Output is correct |
59 |
Correct |
5 ms |
5468 KB |
Output is correct |
60 |
Correct |
5 ms |
5208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
904 ms |
7996 KB |
Output is correct |
2 |
Correct |
907 ms |
8000 KB |
Output is correct |
3 |
Correct |
903 ms |
8000 KB |
Output is correct |
4 |
Correct |
901 ms |
8020 KB |
Output is correct |
5 |
Correct |
902 ms |
8020 KB |
Output is correct |
6 |
Correct |
899 ms |
8016 KB |
Output is correct |
7 |
Correct |
899 ms |
8000 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
3164 KB |
Output is correct |
2 |
Correct |
1 ms |
3164 KB |
Output is correct |
3 |
Correct |
1 ms |
3164 KB |
Output is correct |
4 |
Correct |
1 ms |
3176 KB |
Output is correct |
5 |
Correct |
52 ms |
7768 KB |
Output is correct |
6 |
Correct |
130 ms |
7768 KB |
Output is correct |
7 |
Correct |
276 ms |
7996 KB |
Output is correct |
8 |
Correct |
450 ms |
7772 KB |
Output is correct |
9 |
Correct |
680 ms |
8000 KB |
Output is correct |
10 |
Correct |
419 ms |
8016 KB |
Output is correct |
11 |
Correct |
1 ms |
3164 KB |
Output is correct |
12 |
Correct |
163 ms |
7772 KB |
Output is correct |
13 |
Correct |
164 ms |
7996 KB |
Output is correct |
14 |
Correct |
165 ms |
8012 KB |
Output is correct |
15 |
Correct |
488 ms |
7772 KB |
Output is correct |
16 |
Correct |
485 ms |
8004 KB |
Output is correct |
17 |
Correct |
445 ms |
8004 KB |
Output is correct |
18 |
Correct |
896 ms |
8028 KB |
Output is correct |
19 |
Correct |
833 ms |
7772 KB |
Output is correct |
20 |
Correct |
739 ms |
8000 KB |
Output is correct |
21 |
Correct |
1 ms |
3164 KB |
Output is correct |
22 |
Correct |
1 ms |
3164 KB |
Output is correct |
23 |
Correct |
1 ms |
3160 KB |
Output is correct |
24 |
Correct |
1 ms |
3164 KB |
Output is correct |
25 |
Correct |
2 ms |
3164 KB |
Output is correct |
26 |
Correct |
1 ms |
3164 KB |
Output is correct |
27 |
Correct |
1 ms |
3164 KB |
Output is correct |
28 |
Correct |
1 ms |
3164 KB |
Output is correct |
29 |
Correct |
1 ms |
3120 KB |
Output is correct |
30 |
Correct |
1 ms |
3164 KB |
Output is correct |
31 |
Correct |
1 ms |
3164 KB |
Output is correct |
32 |
Correct |
1 ms |
3164 KB |
Output is correct |
33 |
Correct |
1 ms |
3164 KB |
Output is correct |
34 |
Correct |
1 ms |
3160 KB |
Output is correct |
35 |
Correct |
1 ms |
3164 KB |
Output is correct |
36 |
Correct |
2 ms |
5212 KB |
Output is correct |
37 |
Correct |
2 ms |
5212 KB |
Output is correct |
38 |
Correct |
2 ms |
5212 KB |
Output is correct |
39 |
Correct |
2 ms |
5212 KB |
Output is correct |
40 |
Correct |
2 ms |
5212 KB |
Output is correct |
41 |
Correct |
2 ms |
5212 KB |
Output is correct |
42 |
Correct |
2 ms |
5212 KB |
Output is correct |
43 |
Correct |
2 ms |
5212 KB |
Output is correct |
44 |
Correct |
2 ms |
5212 KB |
Output is correct |
45 |
Correct |
2 ms |
5212 KB |
Output is correct |
46 |
Correct |
2 ms |
5212 KB |
Output is correct |
47 |
Correct |
1 ms |
5328 KB |
Output is correct |
48 |
Correct |
2 ms |
5464 KB |
Output is correct |
49 |
Correct |
2 ms |
5208 KB |
Output is correct |
50 |
Correct |
2 ms |
5316 KB |
Output is correct |
51 |
Correct |
2 ms |
5208 KB |
Output is correct |
52 |
Correct |
2 ms |
5212 KB |
Output is correct |
53 |
Correct |
2 ms |
5212 KB |
Output is correct |
54 |
Correct |
2 ms |
5212 KB |
Output is correct |
55 |
Correct |
2 ms |
5212 KB |
Output is correct |
56 |
Correct |
2 ms |
5212 KB |
Output is correct |
57 |
Correct |
2 ms |
5212 KB |
Output is correct |
58 |
Correct |
2 ms |
5212 KB |
Output is correct |
59 |
Correct |
2 ms |
5212 KB |
Output is correct |
60 |
Correct |
2 ms |
5212 KB |
Output is correct |
61 |
Correct |
3 ms |
5212 KB |
Output is correct |
62 |
Correct |
2 ms |
5212 KB |
Output is correct |
63 |
Correct |
3 ms |
5212 KB |
Output is correct |
64 |
Correct |
3 ms |
5212 KB |
Output is correct |
65 |
Correct |
4 ms |
5212 KB |
Output is correct |
66 |
Correct |
4 ms |
5212 KB |
Output is correct |
67 |
Correct |
5 ms |
5212 KB |
Output is correct |
68 |
Correct |
5 ms |
5216 KB |
Output is correct |
69 |
Correct |
7 ms |
5464 KB |
Output is correct |
70 |
Correct |
7 ms |
5208 KB |
Output is correct |
71 |
Correct |
9 ms |
5212 KB |
Output is correct |
72 |
Correct |
9 ms |
5212 KB |
Output is correct |
73 |
Correct |
5 ms |
5212 KB |
Output is correct |
74 |
Correct |
5 ms |
5328 KB |
Output is correct |
75 |
Correct |
5 ms |
5208 KB |
Output is correct |
76 |
Correct |
5 ms |
5212 KB |
Output is correct |
77 |
Correct |
5 ms |
5212 KB |
Output is correct |
78 |
Correct |
5 ms |
5328 KB |
Output is correct |
79 |
Correct |
5 ms |
5468 KB |
Output is correct |
80 |
Correct |
5 ms |
5208 KB |
Output is correct |
81 |
Correct |
904 ms |
7996 KB |
Output is correct |
82 |
Correct |
907 ms |
8000 KB |
Output is correct |
83 |
Correct |
903 ms |
8000 KB |
Output is correct |
84 |
Correct |
901 ms |
8020 KB |
Output is correct |
85 |
Correct |
902 ms |
8020 KB |
Output is correct |
86 |
Correct |
899 ms |
8016 KB |
Output is correct |
87 |
Correct |
899 ms |
8000 KB |
Output is correct |
88 |
Correct |
53 ms |
7772 KB |
Output is correct |
89 |
Correct |
54 ms |
8028 KB |
Output is correct |
90 |
Correct |
134 ms |
7772 KB |
Output is correct |
91 |
Correct |
134 ms |
8000 KB |
Output is correct |
92 |
Correct |
306 ms |
8000 KB |
Output is correct |
93 |
Correct |
302 ms |
7772 KB |
Output is correct |
94 |
Correct |
549 ms |
8016 KB |
Output is correct |
95 |
Correct |
543 ms |
7772 KB |
Output is correct |
96 |
Correct |
742 ms |
8016 KB |
Output is correct |
97 |
Correct |
747 ms |
8012 KB |
Output is correct |
98 |
Correct |
493 ms |
8000 KB |
Output is correct |
99 |
Correct |
488 ms |
8000 KB |
Output is correct |
100 |
Correct |
493 ms |
8004 KB |
Output is correct |
101 |
Correct |
500 ms |
8020 KB |
Output is correct |
102 |
Correct |
488 ms |
7768 KB |
Output is correct |
103 |
Correct |
488 ms |
8004 KB |
Output is correct |
104 |
Correct |
493 ms |
8004 KB |
Output is correct |
105 |
Correct |
496 ms |
7768 KB |
Output is correct |