This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pl;
typedef vector<ll> vl;
#define FD(i, r, l) for(ll i = r; i > (l); --i)
#define K first
#define V second
#define G(x) ll x; cin >> x;
#define GD(x) ld x; cin >> x;
#define GS(s) string s; cin >> s;
#define EX(x) { cout << x << '\n'; exit(0); }
#define A(a) (a).begin(), (a).end()
#define F(i, l, r) for (ll i = l; i < (r); ++i)
#define NN
#define M 1000000007 // 998244353
int main(){
// freopen("a.in", "r", stdin);
// freopen("a.out", "w", stdout);
ios_base::sync_with_stdio(false); cin.tie(0);
cout << fixed << setprecision(20);
G(n) G(k)
vector<pl> votes(n);
for (auto &[b, a]: votes) {
cin >> a >> b;
}
sort(A(votes));
ld ans = 1e18;
F(take, 0, n+1) {
vector<bool> eaten(n);
ll cum = 0;
ld time = 0;
F(i, 0, n) if (cum < take) {
auto &[b, _] = votes[i];
if (b == -1) continue;
eaten[i] = 1;
time += ld(b)/(cum + 1);
cum++;
}
if (cum < take) continue;
vector<ll> ungotten;
F(i, 0, n) if (!eaten[i]) ungotten.push_back(votes[i].V);
sort(A(ungotten));
ll cur = take;
for (auto x: ungotten) if (cur < k) {
cur++;
time += ld(x)/(take+1);
}
// cout << "WHAT " << take << " " << time << endl;
ans = min(ans, time);
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |