Submission #638803

#TimeUsernameProblemLanguageResultExecution timeMemory
638803penguin133Let's Win the Election (JOI22_ho_t3)C++14
0 / 100
609 ms56240 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define pi pair<int, int> #define pii pair<int, pair<int, int> > #define fi first #define se second int n,k; pair<long double, long double> A[300005]; bool cmp(pair<long double, long double> a, pair<long double, long double> b){ if(a.se == -1)return 0; if(b.se == -1)return 1; return a.se < b.se; } long double dp[105][105][105]; void solve(){ cin >> n >> k; for(int i=1;i<=n;i++)cin >> A[i].fi >> A[i].se; sort(A+1, A+n+1, cmp); for(int i=1;i<=k;i++){ for(int j=0;j<=n;j++){ dp[0][i][j] = 1e18; if(j)dp[0][0][j] = 1e18; } } dp[0][0][0] = 0.0; for(int i=1;i<=n;i++){ for(int j=0;j<=k;j++){ long double bruh = 1e18; for(int x=0;x<=n;x++){ dp[i][j][x] = dp[i-1][j][x]; if(j && x && A[i].se > 0)dp[i][j][x] = min(dp[i][j][x], dp[i-1][j-1][x-1] + A[i].se/x); if(j)dp[i][j][x] = min(dp[i][j][x], dp[i-1][j-1][x] + A[i].fi/(x+1)); bruh = min(bruh, dp[i][j][x]); } } } long double ans = 1e18; for(int i=0;i<=n;i++)ans= min(ans, dp[n][k][i]); cout << fixed << setprecision(12) << ans; } main(){ ios::sync_with_stdio(0);cin.tie(0); int t = 1; //cin >> t; while(t--){ solve(); } }

Compilation message (stderr)

Main.cpp:43:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   43 | main(){
      | ^~~~
#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...