using namespace std;
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
typedef long long LL;
typedef pair<int,int> pii;
#define pb push_back
#define mkp make_pair
#define F first
#define S second
#define iter(x) x.begin(),x.end()
#define REP(n) for (int __=n;__--;)
#define REP0(i,n) for (int i=0;i<n;++i)
#define REP1(i,n) for (int i=1;i<=n;++i)
const int maxn = 0, mod = 0;
const LL inf = 0;
#include <iomanip>
void solve2(int n, int k){
int a[20], b[20];
REP0(i, n) cin >> a[i] >> b[i];
double ans = 1e9;
REP0(mask, 1 << n){
int m = __builtin_popcount(mask);
if (m > k) continue;
bool ok = true;
REP0(i, n) if (((mask >> i) & 1) and b[i] == -1){
ok = false;
break;
}
if (!ok) continue;
vector <int> bs, as;
REP0(i, n){
if ((mask >> i) & 1) bs.pb(b[i]);
else as.pb(a[i]);
}
sort(iter(as));
sort(iter(bs));
double tans = 0;
REP0(i, m) tans += bs[i] * 1.0 / (i+1);
REP0(i, k - m) tans += as[i] * 1.0 / (m+1);
ans = min(ans, tans);
}
cout << ans;
}
void solve(){
cout << fixed << setprecision(15);
int n, k;
cin >> n >> k;
if (n <= 20){
solve2(n, k);
return;
}
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
solve();
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
308 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
308 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
4 ms |
312 KB |
Output is correct |
17 |
Correct |
255 ms |
308 KB |
Output is correct |
18 |
Correct |
60 ms |
204 KB |
Output is correct |
19 |
Correct |
585 ms |
292 KB |
Output is correct |
20 |
Correct |
61 ms |
284 KB |
Output is correct |
21 |
Correct |
41 ms |
204 KB |
Output is correct |
22 |
Correct |
675 ms |
292 KB |
Output is correct |
23 |
Correct |
57 ms |
288 KB |
Output is correct |
24 |
Correct |
15 ms |
288 KB |
Output is correct |
25 |
Correct |
649 ms |
296 KB |
Output is correct |
26 |
Correct |
205 ms |
204 KB |
Output is correct |
27 |
Correct |
588 ms |
304 KB |
Output is correct |
28 |
Correct |
569 ms |
292 KB |
Output is correct |
29 |
Correct |
604 ms |
204 KB |
Output is correct |
30 |
Correct |
629 ms |
292 KB |
Output is correct |
31 |
Correct |
574 ms |
204 KB |
Output is correct |
32 |
Correct |
635 ms |
288 KB |
Output is correct |
33 |
Correct |
600 ms |
296 KB |
Output is correct |
34 |
Correct |
603 ms |
204 KB |
Output is correct |
35 |
Correct |
600 ms |
288 KB |
Output is correct |
36 |
Correct |
590 ms |
292 KB |
Output is correct |
37 |
Correct |
609 ms |
296 KB |
Output is correct |
38 |
Correct |
609 ms |
292 KB |
Output is correct |
39 |
Correct |
617 ms |
204 KB |
Output is correct |
40 |
Correct |
602 ms |
296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
304 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
0 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
204 KB |
Output is correct |
12 |
Correct |
1 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
308 KB |
Output is correct |
15 |
Correct |
0 ms |
204 KB |
Output is correct |
16 |
Correct |
4 ms |
312 KB |
Output is correct |
17 |
Correct |
255 ms |
308 KB |
Output is correct |
18 |
Correct |
60 ms |
204 KB |
Output is correct |
19 |
Correct |
585 ms |
292 KB |
Output is correct |
20 |
Correct |
61 ms |
284 KB |
Output is correct |
21 |
Correct |
41 ms |
204 KB |
Output is correct |
22 |
Correct |
675 ms |
292 KB |
Output is correct |
23 |
Correct |
57 ms |
288 KB |
Output is correct |
24 |
Correct |
15 ms |
288 KB |
Output is correct |
25 |
Correct |
649 ms |
296 KB |
Output is correct |
26 |
Correct |
205 ms |
204 KB |
Output is correct |
27 |
Correct |
588 ms |
304 KB |
Output is correct |
28 |
Correct |
569 ms |
292 KB |
Output is correct |
29 |
Correct |
604 ms |
204 KB |
Output is correct |
30 |
Correct |
629 ms |
292 KB |
Output is correct |
31 |
Correct |
574 ms |
204 KB |
Output is correct |
32 |
Correct |
635 ms |
288 KB |
Output is correct |
33 |
Correct |
600 ms |
296 KB |
Output is correct |
34 |
Correct |
603 ms |
204 KB |
Output is correct |
35 |
Correct |
600 ms |
288 KB |
Output is correct |
36 |
Correct |
590 ms |
292 KB |
Output is correct |
37 |
Correct |
609 ms |
296 KB |
Output is correct |
38 |
Correct |
609 ms |
292 KB |
Output is correct |
39 |
Correct |
617 ms |
204 KB |
Output is correct |
40 |
Correct |
602 ms |
296 KB |
Output is correct |
41 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
42 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
308 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |