# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
549668 | cpp219 | Let's Win the Election (JOI22_ho_t3) | C++17 | 9 ms | 364 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 ll long long
#define ld long double
#define fs first
#define sc second
#define debug(y) cout<<y,exit(0)
using namespace std;
typedef pair<ll,ll> LL;
const ll N = 500 + 9;
const ll inf = 1e18 + 7;
ld ans = inf*1.0;
ll n,k,collab;
LL a[N];
bool lf(LL x,LL y){
return x.sc < y.sc;
}
int main(){
ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
#define task "tst"
if (fopen(task".inp","r")){
freopen(task".inp","r",stdin);
//freopen(task".out","w",stdout);
}
cin>>n>>k;
for (ll i = 1;i <= n;i++){
cin>>a[i].fs>>a[i].sc;
if (a[i].sc == -1) a[i].sc = inf;
collab += (a[i].sc != -1);
}
sort(a + 1,a + n + 1,lf);
for (ll take = 0;take <= min(k,collab);take++){
ll man = 1; ld tmp = 0; vector<LL> rm;
for (ll i = 1;i <= take;i++){
tmp += (ld)a[i].sc/man; man++;
}
for (ll i = take + 1;i <= n;i++) rm.push_back(a[i]);
sort(rm.begin(),rm.end());
for (ll i = 0;i < k - take;i++) tmp += (ld) rm[i].fs/man;
ans = min(ans,tmp); //debug(tmp);
}
cout<<fixed<<setprecision(6)<<ans;
}
/// be confident
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... |