# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
529438 | wiwiho | Let's Win the Election (JOI22_ho_t3) | C++14 | 18 ms | 332 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define iter(a) a.begin(), a.end()
#define mp make_pair
#define F first
#define S second
#define eb emplace_back
#define lsort(a) sort(iter(a))
#define gsort(a) sort(iter(a), greater<>())
using namespace std;
typedef long long ll;
typedef long double ld;
using pii = pair<int, int>;
ll iceil(ll a, ll b){
return (a + b - 1) / b;
}
int n, k;
vector<int> a, b;
ld calc(int cnt){
vector<pii> tmp;
for(int i = 1; i <= n; i++){
if(b[i] == -1) continue;
tmp.eb(mp(b[i], i));
}
if(tmp.size() < cnt) return 1e87;
lsort(tmp);
vector<bool> use(n + 1);
ld ans = 0;
for(int i = 0; i < cnt; i++){
use[tmp[i].S] = true;
ans += (ld)tmp[i].F / (i + 1);
}
tmp.clear();
for(int i = 1; i <= n; i++){
if(use[i]) continue;
tmp.eb(mp(a[i], i));
}
lsort(tmp);
for(int i = 0; i < k - cnt; i++){
ans += (ld)tmp[i].F / (cnt + 1);
}
return ans;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n >> k;
a.resize(n + 1);
b.resize(n + 1);
for(int i = 1; i <= n; i++) cin >> a[i] >> b[i];
ld ans = 1e87;
for(int i = 0; i <= k; i++) ans = min(ans, calc(i));
cout << fixed << setprecision(20) << ans << "\n";
return 0;
}
Compilation message (stderr)
# | 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... |