Submission #533602

#TimeUsernameProblemLanguageResultExecution timeMemory
533602victor_gaoLet's Win the Election (JOI22_ho_t3)C++17
56 / 100
499 ms19204 KiB
//#pragma GCC optimize("Ofast,unroll-loops,O3") //#pragma GCC target("avx,avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,fma,tune=native") #include<bits/stdc++.h> //#include<bits/extc++.h> //#pragma pack(1) #define fast ios::sync_with_stdio(0); cin.tie(0); #define int long long #define pii pair<int,int> #define x first #define y second #define N 115 using namespace std; //using namespace __gnu_pbds; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); //typedef tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> order_multiset; //typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> order_set; int n,k; pii arr[N]; long double dp[N][N][N],ans=1e100; bool vis[N]; vector<pii>tog,all; long double solve(int use){ for (int i=0;i<=n;i++){ for (int j=0;j<=n;j++) dp[0][i][j]=1e18; } dp[0][0][0]=0; for (int i=1;i<=n;i++){ for (int j=0;j<=n;j++){ for (int h=0;h<=use;h++){ dp[i][j][h]=dp[i-1][j][h]; if (j&&j<=i) dp[i][j][h]=min(dp[i-1][j-1][h]+(long double)(arr[i].x)/(use+1),dp[i][j][h]); if (arr[i].y!=-1&&h&&h<=i&&j<=i&&j){ dp[i][j][h]=min(dp[i][j][h],dp[i-1][j-1][h-1]+(long double)(arr[i].y)/(h)); } // cout<<dp[i][j][h]<<' '; } // cout<<'\n'; } // cout<<'\n'; } // cout<<'\n'; return dp[n][k][use]; } bool cmp(pii a,pii b){ if (a.y!=b.y) return a.y<b.y; return a.x<b.x; } signed main(){ fast cout<<fixed<<setprecision(20); cin>>n>>k; for (int i=1;i<=n;i++) cin>>arr[i].x>>arr[i].y; sort(arr+1,arr+1+n,cmp); for (int i=0;i<=k;i++){ ans=min(ans,solve(i)); } cout<<ans<<'\n'; }
#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...