Submission #551150

#TimeUsernameProblemLanguageResultExecution timeMemory
551150DanerZeinLet's Win the Election (JOI22_ho_t3)C++14
56 / 100
378 ms21548 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[110][110][110]; double knap(int id,int k,int ca){ if(dp[id][k][ca]!=-1) return dp[id][k][ca]; if(id==n) { if(ca==0 && k==ka) return 0; return MAX; } double ans=knap(id+1,k,ca); if(ca!=0){ ans=min(ans,knap(id+1,k,ca-1)+st[id].first/(ka+1)); if(k!=ka) ans=min(ans,knap(id+1,k+1,ca-1)+st[id].second/(double)(k+1)); } return dp[id][k][ca]=ans; } int main(){ int k; scanf("%d%d",&n,&k); for(int i=0;i<n;i++){ int a,b; scanf("%d%d",&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; for(int id=0;id<=n;id++) for(int kk=0;kk<=n;kk++) for(int ca=0;ca<=n;ca++) dp[id][kk][ca]=-1; double rp=knap(0,0,k); //cout<<i<<": "<<rp<<endl; res=min(res,rp); } printf("%.15f\n",res); }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:29:15: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   int k; scanf("%d%d",&n,&k);
      |          ~~~~~^~~~~~~~~~~~~~
Main.cpp:31:19: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     int a,b; scanf("%d%d",&a,&b);
      |              ~~~~~^~~~~~~~~~~~~~
#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...