Submission #936940

#TimeUsernameProblemLanguageResultExecution timeMemory
936940Marco_EscandonLet's Win the Election (JOI22_ho_t3)C++11
10 / 100
2052 ms9048 KiB
#include<bits/stdc++.h> #define optimizar_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout.setf(ios::fixed);cout.precision(15); #pragma GCC optimize("Ofast") using namespace std; typedef long long ll; #define x first #define y second pair<double,double> cad[501]; pair<double,double> dp[3][503][503]; int main() { optimizar_io ll n,m; cin>>n>>m; cad[0]={-1,-1}; for(int i=1; i<=n; i++) cin>>cad[i].second>>cad[i].first; sort(cad,cad+n+1); for(int i=0; i<2; i++) for(int j=0; j<=n; j++) for(int k=0; k<=m+2; k++) dp[i][j][k]={1e9,1e9}; dp[0][1][1]={0,0}; double bs=1e9; for(int i=1; i<=n; i++) { for(int j=1; j<=n; j++) { for(int k=1; k<=m+1; k++) { pair<double,double> temp={1e9,1e9}; temp=min(temp,dp[0][j][k]); temp=min(temp,{dp[0][j][k-1].x+cad[i].y/j,dp[0][j][k-1].y}); if(cad[i].first!=-1&&j!=1) temp=min(temp,{(dp[0][j-1][k-1].x-dp[0][j-1][k-1].y)*(j-1)/j+dp[0][j-1][k-1].y+cad[i].x/(j-1),dp[0][j-1][k-1].y+cad[i].x/(j-1)}); dp[1][j][k]=temp; if(k==m+1) bs=min(bs,dp[1][j][k].first); } //cout<<"\n"; } swap(dp[0],dp[1]); //cout<<"\n\n"; } cout<<bs; }
#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...