#include <bits/stdc++.h>
using namespace std;
#define int long long
#define db long double
#define MAX 502
int n, k;
pair<db, db> info[MAX];
bool cmp(pair<db, db> a, pair<db, db> b){
if (a.second == -1) a.second = 1000000000;
if (b.second == -1) b.second = 1000000000;
return a.second > b.second;
}
main(){
cin >> n >> k;
for (int x = 0; x < n; x++) cin >> info[x].first >> info[x].second;
db ans = 1000000000000000LL;
for (int x = 0; x <= n; x++){
//make use of x colabs
//initial sort is optimal for 0 colabs
vector<pair<db, db>> colabSect;
vector<pair<db, db>> voteSect;
//wait is dp even needed
for (int y = 0; y < n; y++) voteSect.push_back(info[y]);
sort(voteSect.begin(), voteSect.end(), cmp); //give cheapest
for (int y = 0; y < x; y++){
colabSect.push_back(voteSect.back());
//cout << voteSect.back().first << ' ' << voteSect.back().second << '\n';
voteSect.pop_back();
}
//cout << '\n' << '\n';
if (colabSect.size() != 0 && colabSect.back().second == -1) break;
sort(voteSect.begin(), voteSect.end()); //return to cheapest votes
int votesNeeded = max(k - (int)colabSect.size(), 0LL);
int colabCount = 1;
db curAns = 0;
for (auto y : colabSect){
curAns += y.second/colabCount; colabCount++;
}
for (int y = 0; y < votesNeeded; y++){
curAns += voteSect[y].first/colabCount;
}
//cout << curAns << "!!!\n\n";
ans = min(curAns, ans);
}
cout << std::setprecision(9) << ans;
}
Compilation message
Main.cpp:19:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
19 | main(){
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
55 ms |
344 KB |
Output is correct |
13 |
Correct |
38 ms |
340 KB |
Output is correct |
14 |
Correct |
15 ms |
340 KB |
Output is correct |
15 |
Correct |
58 ms |
340 KB |
Output is correct |
16 |
Correct |
31 ms |
348 KB |
Output is correct |
17 |
Correct |
11 ms |
340 KB |
Output is correct |
18 |
Correct |
56 ms |
348 KB |
Output is correct |
19 |
Correct |
33 ms |
340 KB |
Output is correct |
20 |
Correct |
10 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
64 ms |
352 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
55 ms |
344 KB |
Output is correct |
13 |
Correct |
38 ms |
340 KB |
Output is correct |
14 |
Correct |
15 ms |
340 KB |
Output is correct |
15 |
Correct |
58 ms |
340 KB |
Output is correct |
16 |
Correct |
31 ms |
348 KB |
Output is correct |
17 |
Correct |
11 ms |
340 KB |
Output is correct |
18 |
Correct |
56 ms |
348 KB |
Output is correct |
19 |
Correct |
33 ms |
340 KB |
Output is correct |
20 |
Correct |
10 ms |
340 KB |
Output is correct |
21 |
Correct |
0 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
0 ms |
212 KB |
Output is correct |
27 |
Correct |
0 ms |
212 KB |
Output is correct |
28 |
Correct |
0 ms |
212 KB |
Output is correct |
29 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
30 |
Halted |
0 ms |
0 KB |
- |