#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,unroll-loops")
#define ll long long
#define int ll
#define ull unsigned ll
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define chkmin(a,b) (a=min(a,b))
#define chkmax(a,b) (a=max(a,b))
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
//#define inf 1010000000
#define inf 4000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#ifdef i_am_noob
#define bug(...) cerr << "#" << __LINE__ << ' ' << #__VA_ARGS__ << "- ", _do(__VA_ARGS__)
template<typename T> void _do(T && x) {cerr << x << endl;}
template<typename T, typename ...S> void _do(T && x, S&&...y) {cerr << x << ", "; _do(y...);}
#else
#define bug(...) 777771449
#endif
const int mod=1000000007;
const int maxn=505,maxm=5,maxk=7777714;
//i_am_noob
int n,k;
pair<double,double> a[maxn];
double res=inf;
double dp[maxn][maxn][maxn];
bool cmp(pair<double,double> x, pair<double,double> y){return x.second<y.second;}
void orzck(){
cin >> n >> k;
rep(n){
int x,y;
cin >> x >> y;
if(y==-1) y=1e9;
a[i].first=x,a[i].second=y;
}
sort(a,a+n,cmp);
rep(n+1) rep1(j,n+1) dp[i][0][j]=inf;
rep(n+1) dp[i][0][0]=0;
rep(n+1){
rep2(j,1,n+1) rep1(k,i+1){
dp[i][j][k]=inf;
if(k>0) chkmin(dp[i][j][k],dp[i][j-1][k-1]+a[j-1].second/k);
chkmin(dp[i][j][k],dp[i][j-1][k]+a[j-1].first/(i+1));
}
}
bug("de");
multiset<double> st;
double tot=0;
rep3(i,n,0){
if(i<n) st.insert(a[i].first);
if(i>k) continue;
if(i<k){
tot+=*st.begin();
st.erase(st.begin());
}
bug(i,tot);
rep1(j,i+1){
chkmin(res,dp[j][i][j]+tot/(j+1));
//bug(i,j,dp[j][i][j]+tot/(j+1));
}
}
cout << fixed << setprecision(12);
cout << res << "\n";
}
signed main(){
ios_base::sync_with_stdio(0),cin.tie(0);
orzck();
return 0;
}
Compilation message
Main.cpp: In function 'void orzck()':
Main.cpp:31:18: warning: statement has no effect [-Wunused-value]
31 | #define bug(...) 777771449
| ^~~~~~~~~
Main.cpp:63:5: note: in expansion of macro 'bug'
63 | bug("de");
| ^~~
Main.cpp:31:18: warning: statement has no effect [-Wunused-value]
31 | #define bug(...) 777771449
| ^~~~~~~~~
Main.cpp:73:9: note: in expansion of macro 'bug'
73 | bug(i,tot);
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
823 ms |
993568 KB |
Output is correct |
6 |
Correct |
777 ms |
993532 KB |
Output is correct |
7 |
Correct |
781 ms |
993512 KB |
Output is correct |
8 |
Correct |
781 ms |
993440 KB |
Output is correct |
9 |
Correct |
782 ms |
993452 KB |
Output is correct |
10 |
Correct |
775 ms |
993460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
823 ms |
993568 KB |
Output is correct |
6 |
Correct |
777 ms |
993532 KB |
Output is correct |
7 |
Correct |
781 ms |
993512 KB |
Output is correct |
8 |
Correct |
781 ms |
993440 KB |
Output is correct |
9 |
Correct |
782 ms |
993452 KB |
Output is correct |
10 |
Correct |
775 ms |
993460 KB |
Output is correct |
11 |
Correct |
1 ms |
320 KB |
Output is correct |
12 |
Correct |
764 ms |
993448 KB |
Output is correct |
13 |
Correct |
778 ms |
993520 KB |
Output is correct |
14 |
Correct |
807 ms |
993568 KB |
Output is correct |
15 |
Correct |
758 ms |
993580 KB |
Output is correct |
16 |
Correct |
757 ms |
993768 KB |
Output is correct |
17 |
Correct |
786 ms |
993676 KB |
Output is correct |
18 |
Correct |
772 ms |
993604 KB |
Output is correct |
19 |
Correct |
779 ms |
993452 KB |
Output is correct |
20 |
Correct |
764 ms |
993464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
580 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 |
588 KB |
Output is correct |
12 |
Correct |
1 ms |
576 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 |
# |
Verdict |
Execution time |
Memory |
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 |
580 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 |
588 KB |
Output is correct |
12 |
Correct |
1 ms |
576 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 |
2 ms |
2124 KB |
Output is correct |
17 |
Correct |
1 ms |
2120 KB |
Output is correct |
18 |
Correct |
1 ms |
2124 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 |
2116 KB |
Output is correct |
23 |
Correct |
1 ms |
2124 KB |
Output is correct |
24 |
Correct |
1 ms |
2116 KB |
Output is correct |
25 |
Correct |
1 ms |
2124 KB |
Output is correct |
26 |
Correct |
1 ms |
2124 KB |
Output is correct |
27 |
Correct |
2 ms |
2124 KB |
Output is correct |
28 |
Correct |
1 ms |
2124 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 |
1 ms |
2124 KB |
Output is correct |
33 |
Correct |
1 ms |
2124 KB |
Output is correct |
34 |
Correct |
1 ms |
2116 KB |
Output is correct |
35 |
Correct |
1 ms |
2124 KB |
Output is correct |
36 |
Correct |
2 ms |
2124 KB |
Output is correct |
37 |
Correct |
1 ms |
2124 KB |
Output is correct |
38 |
Correct |
1 ms |
2124 KB |
Output is correct |
39 |
Correct |
2 ms |
2116 KB |
Output is correct |
40 |
Correct |
1 ms |
2124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
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 |
580 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 |
588 KB |
Output is correct |
12 |
Correct |
1 ms |
576 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 |
2 ms |
2124 KB |
Output is correct |
17 |
Correct |
1 ms |
2120 KB |
Output is correct |
18 |
Correct |
1 ms |
2124 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 |
2116 KB |
Output is correct |
23 |
Correct |
1 ms |
2124 KB |
Output is correct |
24 |
Correct |
1 ms |
2116 KB |
Output is correct |
25 |
Correct |
1 ms |
2124 KB |
Output is correct |
26 |
Correct |
1 ms |
2124 KB |
Output is correct |
27 |
Correct |
2 ms |
2124 KB |
Output is correct |
28 |
Correct |
1 ms |
2124 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 |
1 ms |
2124 KB |
Output is correct |
33 |
Correct |
1 ms |
2124 KB |
Output is correct |
34 |
Correct |
1 ms |
2116 KB |
Output is correct |
35 |
Correct |
1 ms |
2124 KB |
Output is correct |
36 |
Correct |
2 ms |
2124 KB |
Output is correct |
37 |
Correct |
1 ms |
2124 KB |
Output is correct |
38 |
Correct |
1 ms |
2124 KB |
Output is correct |
39 |
Correct |
2 ms |
2116 KB |
Output is correct |
40 |
Correct |
1 ms |
2124 KB |
Output is correct |
41 |
Correct |
21 ms |
40992 KB |
Output is correct |
42 |
Correct |
20 ms |
40908 KB |
Output is correct |
43 |
Correct |
20 ms |
40896 KB |
Output is correct |
44 |
Correct |
21 ms |
40908 KB |
Output is correct |
45 |
Correct |
20 ms |
40996 KB |
Output is correct |
46 |
Correct |
20 ms |
40904 KB |
Output is correct |
47 |
Correct |
21 ms |
40924 KB |
Output is correct |
48 |
Correct |
20 ms |
40900 KB |
Output is correct |
49 |
Correct |
21 ms |
40908 KB |
Output is correct |
50 |
Correct |
22 ms |
41008 KB |
Output is correct |
51 |
Correct |
21 ms |
40952 KB |
Output is correct |
52 |
Correct |
21 ms |
40892 KB |
Output is correct |
53 |
Correct |
20 ms |
40904 KB |
Output is correct |
54 |
Correct |
20 ms |
40900 KB |
Output is correct |
55 |
Correct |
24 ms |
40940 KB |
Output is correct |
56 |
Correct |
20 ms |
40984 KB |
Output is correct |
57 |
Correct |
20 ms |
41008 KB |
Output is correct |
58 |
Correct |
21 ms |
40924 KB |
Output is correct |
59 |
Correct |
19 ms |
40908 KB |
Output is correct |
60 |
Correct |
20 ms |
40908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
790 ms |
993576 KB |
Output is correct |
2 |
Correct |
765 ms |
993532 KB |
Output is correct |
3 |
Correct |
772 ms |
993472 KB |
Output is correct |
4 |
Correct |
761 ms |
993464 KB |
Output is correct |
5 |
Correct |
767 ms |
993472 KB |
Output is correct |
6 |
Correct |
767 ms |
993476 KB |
Output is correct |
7 |
Correct |
764 ms |
993472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
364 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
823 ms |
993568 KB |
Output is correct |
6 |
Correct |
777 ms |
993532 KB |
Output is correct |
7 |
Correct |
781 ms |
993512 KB |
Output is correct |
8 |
Correct |
781 ms |
993440 KB |
Output is correct |
9 |
Correct |
782 ms |
993452 KB |
Output is correct |
10 |
Correct |
775 ms |
993460 KB |
Output is correct |
11 |
Correct |
1 ms |
320 KB |
Output is correct |
12 |
Correct |
764 ms |
993448 KB |
Output is correct |
13 |
Correct |
778 ms |
993520 KB |
Output is correct |
14 |
Correct |
807 ms |
993568 KB |
Output is correct |
15 |
Correct |
758 ms |
993580 KB |
Output is correct |
16 |
Correct |
757 ms |
993768 KB |
Output is correct |
17 |
Correct |
786 ms |
993676 KB |
Output is correct |
18 |
Correct |
772 ms |
993604 KB |
Output is correct |
19 |
Correct |
779 ms |
993452 KB |
Output is correct |
20 |
Correct |
764 ms |
993464 KB |
Output is correct |
21 |
Correct |
1 ms |
588 KB |
Output is correct |
22 |
Correct |
1 ms |
588 KB |
Output is correct |
23 |
Correct |
1 ms |
588 KB |
Output is correct |
24 |
Correct |
1 ms |
588 KB |
Output is correct |
25 |
Correct |
1 ms |
588 KB |
Output is correct |
26 |
Correct |
1 ms |
588 KB |
Output is correct |
27 |
Correct |
1 ms |
588 KB |
Output is correct |
28 |
Correct |
1 ms |
580 KB |
Output is correct |
29 |
Correct |
1 ms |
588 KB |
Output is correct |
30 |
Correct |
1 ms |
588 KB |
Output is correct |
31 |
Correct |
1 ms |
588 KB |
Output is correct |
32 |
Correct |
1 ms |
576 KB |
Output is correct |
33 |
Correct |
1 ms |
588 KB |
Output is correct |
34 |
Correct |
1 ms |
460 KB |
Output is correct |
35 |
Correct |
1 ms |
588 KB |
Output is correct |
36 |
Correct |
2 ms |
2124 KB |
Output is correct |
37 |
Correct |
1 ms |
2120 KB |
Output is correct |
38 |
Correct |
1 ms |
2124 KB |
Output is correct |
39 |
Correct |
1 ms |
2124 KB |
Output is correct |
40 |
Correct |
1 ms |
2124 KB |
Output is correct |
41 |
Correct |
2 ms |
2124 KB |
Output is correct |
42 |
Correct |
1 ms |
2116 KB |
Output is correct |
43 |
Correct |
1 ms |
2124 KB |
Output is correct |
44 |
Correct |
1 ms |
2116 KB |
Output is correct |
45 |
Correct |
1 ms |
2124 KB |
Output is correct |
46 |
Correct |
1 ms |
2124 KB |
Output is correct |
47 |
Correct |
2 ms |
2124 KB |
Output is correct |
48 |
Correct |
1 ms |
2124 KB |
Output is correct |
49 |
Correct |
1 ms |
2124 KB |
Output is correct |
50 |
Correct |
1 ms |
2124 KB |
Output is correct |
51 |
Correct |
1 ms |
2124 KB |
Output is correct |
52 |
Correct |
1 ms |
2124 KB |
Output is correct |
53 |
Correct |
1 ms |
2124 KB |
Output is correct |
54 |
Correct |
1 ms |
2116 KB |
Output is correct |
55 |
Correct |
1 ms |
2124 KB |
Output is correct |
56 |
Correct |
2 ms |
2124 KB |
Output is correct |
57 |
Correct |
1 ms |
2124 KB |
Output is correct |
58 |
Correct |
1 ms |
2124 KB |
Output is correct |
59 |
Correct |
2 ms |
2116 KB |
Output is correct |
60 |
Correct |
1 ms |
2124 KB |
Output is correct |
61 |
Correct |
21 ms |
40992 KB |
Output is correct |
62 |
Correct |
20 ms |
40908 KB |
Output is correct |
63 |
Correct |
20 ms |
40896 KB |
Output is correct |
64 |
Correct |
21 ms |
40908 KB |
Output is correct |
65 |
Correct |
20 ms |
40996 KB |
Output is correct |
66 |
Correct |
20 ms |
40904 KB |
Output is correct |
67 |
Correct |
21 ms |
40924 KB |
Output is correct |
68 |
Correct |
20 ms |
40900 KB |
Output is correct |
69 |
Correct |
21 ms |
40908 KB |
Output is correct |
70 |
Correct |
22 ms |
41008 KB |
Output is correct |
71 |
Correct |
21 ms |
40952 KB |
Output is correct |
72 |
Correct |
21 ms |
40892 KB |
Output is correct |
73 |
Correct |
20 ms |
40904 KB |
Output is correct |
74 |
Correct |
20 ms |
40900 KB |
Output is correct |
75 |
Correct |
24 ms |
40940 KB |
Output is correct |
76 |
Correct |
20 ms |
40984 KB |
Output is correct |
77 |
Correct |
20 ms |
41008 KB |
Output is correct |
78 |
Correct |
21 ms |
40924 KB |
Output is correct |
79 |
Correct |
19 ms |
40908 KB |
Output is correct |
80 |
Correct |
20 ms |
40908 KB |
Output is correct |
81 |
Correct |
790 ms |
993576 KB |
Output is correct |
82 |
Correct |
765 ms |
993532 KB |
Output is correct |
83 |
Correct |
772 ms |
993472 KB |
Output is correct |
84 |
Correct |
761 ms |
993464 KB |
Output is correct |
85 |
Correct |
767 ms |
993472 KB |
Output is correct |
86 |
Correct |
767 ms |
993476 KB |
Output is correct |
87 |
Correct |
764 ms |
993472 KB |
Output is correct |
88 |
Correct |
768 ms |
993448 KB |
Output is correct |
89 |
Correct |
753 ms |
993468 KB |
Output is correct |
90 |
Correct |
764 ms |
993644 KB |
Output is correct |
91 |
Correct |
765 ms |
993476 KB |
Output is correct |
92 |
Correct |
779 ms |
993532 KB |
Output is correct |
93 |
Correct |
774 ms |
993440 KB |
Output is correct |
94 |
Correct |
821 ms |
993588 KB |
Output is correct |
95 |
Correct |
792 ms |
993460 KB |
Output is correct |
96 |
Correct |
769 ms |
993456 KB |
Output is correct |
97 |
Correct |
752 ms |
993544 KB |
Output is correct |
98 |
Correct |
752 ms |
993476 KB |
Output is correct |
99 |
Correct |
771 ms |
993476 KB |
Output is correct |
100 |
Correct |
785 ms |
993480 KB |
Output is correct |
101 |
Correct |
758 ms |
993644 KB |
Output is correct |
102 |
Correct |
770 ms |
993680 KB |
Output is correct |
103 |
Correct |
765 ms |
993476 KB |
Output is correct |
104 |
Correct |
759 ms |
993648 KB |
Output is correct |
105 |
Correct |
761 ms |
993516 KB |
Output is correct |