Submission #551142

#TimeUsernameProblemLanguageResultExecution timeMemory
551142DanerZeinLet's Win the Election (JOI22_ho_t3)C++14
0 / 100
2594 ms2260 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<double,double> dd; const int MAX=1e9; bool orden(dd a,dd b){ if(a.second==b.second) return a.first<b.first; return a.second<b.second; } int n; vector<dd> st; double ka; double dp[510][510]; double knap(int id,int k){ if(id==n) { if(k!=ka) return MAX; return 0; } double ans=knap(id+1,k)+st[id].first/(ka+1); if(k!=ka){ ans=min(ans,knap(id+1,k+1)+st[id].second/(double)(k+1)); } return dp[id][k]=ans; } int main(){ int k; cin>>n>>k; for(int i=0;i<n;i++){ int a,b; cin>>a>>b; if(b==-1) b=MAX; st.push_back(dd(a,b)); } sort(st.begin(),st.end(),orden); double res=MAX; for(int i=0;i<=k;i++){ ka=i; memset(dp,-1,sizeof dp); double rp=knap(0,0); //cout<<i<<": "<<rp<<endl; res=min(res,rp); } printf("%.15f\n",res); }
#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...