# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
865458 | NotLinux | Let's Win the Election (JOI22_ho_t3) | C++17 | 9 ms | 348 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>
using namespace std;
#define int long long
void solve(){
int n,k;cin >> n >> k;
int a[n],b[n];
vector < pair < int , int > > v;
for(int i = 0;i<n;i++){
cin >> a[i] >> b[i];
if(b[i] != -1){
v.push_back({b[i],i});
}
}
sort(v.begin() , v.end());
long double ans = 1e18 + 7;
for(int t = 0;t<=v.size();t++){
vector < int > tempa(n);
for(int i = 0;i<n;i++)tempa[i] = a[i];
long double curans = 0;
for(int i = t-1;i>=0;i--){
curans += (long double)v[i].first / (long double)(t - i);
tempa[v[i].second] = 0;
}
cout << curans << endl;
sort(tempa.begin() , tempa.end());
for(int i = 0;i<k;i++){
curans += (long double)tempa[i] / (long double)(t+1);
}
cout << curans << endl;
ans = min(ans , curans);
}
cout << fixed << setprecision(6) << ans << endl;
}
signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int testcase = 1;//cin >> testcase;
while(testcase--)solve();
}
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... |