Submission #658647

#TimeUsernameProblemLanguageResultExecution timeMemory
658647Darren0724Let's Win the Election (JOI22_ho_t3)C++17
10 / 100
11 ms340 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define all(x) x.begin(),x.end() #define double long double int INF=1e9; signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n;cin>>n; int k;cin>>k; vector<int> a(n),b(n); for(int i=0;i<n;i++){ cin>>a[i]; cin>>b[i]; if(b[i]==-1){ b[i]=INF; } } double ans=INF; for(int i=0;i<=k;i++){ double cnt=0; vector<bool> vis(n); vector<int> c(n); iota(all(c),0); sort(all(c),[&](int i,int j){return b[i]<b[j];}); for(int j=0;j<i;j++){ int p=c[j]; vis[p]=1; cnt+=b[p]/(double)(j+1); } sort(all(c),[&](int i,int j){return a[i]<a[j];}); int ptr=0; for(int j=0;j<k-i;j++){ while(vis[c[ptr]]){ ptr++; } int p=c[ptr]; vis[p]=1; cnt+=a[p]/(double)(i+1); ptr++; } ans=min(ans,cnt); } cout<<fixed<<setprecision(9)<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...