#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n,k;
cin>>n>>k;
ll a[n+5],b[n+5],tot=1;
for(ll i=1;i<=n;i++){
cin>>a[i]>>b[i];
if(n<=20){
tot=tot*2;
}
}
vector<ll>v1,v2;
double ans=1e18;
for(ll p=0;p<tot;p++){
ll c=p;
v1.clear();
v2.clear();
for(ll i=1;i<=n;i++){
if(c%2==0){
v1.pb(a[i]);
}
else{
if(b[i]>-1){
v2.pb(b[i]);
}
}
c/=2;
}
sort(all(v1));
sort(all(v2));
double cur=0;
for(ll i=0;i<=min((ll)v2.size(),k);i++){
if(i+v1.size()>=k){
double T=0;
for(ll j=0;j<k-i;j++){
T+=v1[j];
}
ans=min(ans,cur+(double)T/(i+1));
}
if(i<v2.size()){
cur+=(double)v2[i]/(i+1);
}
}
}
printf("%.10f",ans);
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:44:27: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'long long int' [-Wsign-compare]
44 | if(i+v1.size()>=k){
| ~~~~~~~~~~~^~~
Main.cpp:51:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
51 | if(i<v2.size()){
| ~^~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
600 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
600 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
249 ms |
428 KB |
Output is correct |
17 |
Correct |
256 ms |
428 KB |
Output is correct |
18 |
Correct |
228 ms |
592 KB |
Output is correct |
19 |
Correct |
267 ms |
348 KB |
Output is correct |
20 |
Correct |
261 ms |
348 KB |
Output is correct |
21 |
Correct |
231 ms |
348 KB |
Output is correct |
22 |
Correct |
260 ms |
348 KB |
Output is correct |
23 |
Correct |
261 ms |
432 KB |
Output is correct |
24 |
Correct |
247 ms |
432 KB |
Output is correct |
25 |
Correct |
262 ms |
432 KB |
Output is correct |
26 |
Correct |
242 ms |
444 KB |
Output is correct |
27 |
Correct |
293 ms |
428 KB |
Output is correct |
28 |
Correct |
262 ms |
596 KB |
Output is correct |
29 |
Correct |
269 ms |
432 KB |
Output is correct |
30 |
Correct |
262 ms |
428 KB |
Output is correct |
31 |
Correct |
274 ms |
440 KB |
Output is correct |
32 |
Correct |
260 ms |
344 KB |
Output is correct |
33 |
Correct |
290 ms |
348 KB |
Output is correct |
34 |
Correct |
268 ms |
436 KB |
Output is correct |
35 |
Correct |
260 ms |
432 KB |
Output is correct |
36 |
Correct |
274 ms |
428 KB |
Output is correct |
37 |
Correct |
261 ms |
592 KB |
Output is correct |
38 |
Correct |
257 ms |
348 KB |
Output is correct |
39 |
Correct |
279 ms |
432 KB |
Output is correct |
40 |
Correct |
273 ms |
432 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
344 KB |
Output is correct |
4 |
Correct |
0 ms |
600 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
249 ms |
428 KB |
Output is correct |
17 |
Correct |
256 ms |
428 KB |
Output is correct |
18 |
Correct |
228 ms |
592 KB |
Output is correct |
19 |
Correct |
267 ms |
348 KB |
Output is correct |
20 |
Correct |
261 ms |
348 KB |
Output is correct |
21 |
Correct |
231 ms |
348 KB |
Output is correct |
22 |
Correct |
260 ms |
348 KB |
Output is correct |
23 |
Correct |
261 ms |
432 KB |
Output is correct |
24 |
Correct |
247 ms |
432 KB |
Output is correct |
25 |
Correct |
262 ms |
432 KB |
Output is correct |
26 |
Correct |
242 ms |
444 KB |
Output is correct |
27 |
Correct |
293 ms |
428 KB |
Output is correct |
28 |
Correct |
262 ms |
596 KB |
Output is correct |
29 |
Correct |
269 ms |
432 KB |
Output is correct |
30 |
Correct |
262 ms |
428 KB |
Output is correct |
31 |
Correct |
274 ms |
440 KB |
Output is correct |
32 |
Correct |
260 ms |
344 KB |
Output is correct |
33 |
Correct |
290 ms |
348 KB |
Output is correct |
34 |
Correct |
268 ms |
436 KB |
Output is correct |
35 |
Correct |
260 ms |
432 KB |
Output is correct |
36 |
Correct |
274 ms |
428 KB |
Output is correct |
37 |
Correct |
261 ms |
592 KB |
Output is correct |
38 |
Correct |
257 ms |
348 KB |
Output is correct |
39 |
Correct |
279 ms |
432 KB |
Output is correct |
40 |
Correct |
273 ms |
432 KB |
Output is correct |
41 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
42 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
13 |
Halted |
0 ms |
0 KB |
- |