Submission #866577

#TimeUsernameProblemLanguageResultExecution timeMemory
866577NotLinuxLet's Win the Election (JOI22_ho_t3)C++17
100 / 100
1834 ms4440 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 505; const int inf = 1ll << 60; int n,k,a[N],b[N]; long double eval(int x){ if((k-x) < 0){ return inf; } long double dp[n+2][n+2]; for(int i = 0;i<=n;i++){ for(int j = 0;j<=n;j++){ dp[i][j] = 1e18 + 7; } } dp[0][0] = 0; for(int i = 0;i<n;i++){ for(int j = 0;j<=n;j++){ //ai alır dp[i+1][j+1] = min(dp[i+1][j+1] , dp[i][j] + (long double)a[i] / (long double)(x+1)); //bi / almaz if((i+1-j) <= x){ dp[i+1][j] = min(dp[i+1][j] , dp[i][j] + (long double)b[i] / (long double)(i+1-j)); } else { dp[i+1][j] = min(dp[i+1][j] , dp[i][j]); } } } return dp[n][k-x]; } void solve(){ cin >> n >> k; pair < int , int > arr[n]; int sayac = n; for(int i = 0;i<n;i++){ cin >> arr[i].second >> arr[i].first; if(arr[i].first == -1){ arr[i].first = inf; sayac--; } } sort(arr , arr + n); for(int i = 0;i<n;i++){ a[i] = arr[i].second; b[i] = arr[i].first; } long double ans = 1e18 + 7; for(int i = 0;i<=sayac;i++){ ans = min(ans , eval(i)); } cout << fixed << setprecision(9) << ans << endl; } signed main(){ ios_base::sync_with_stdio(0);cin.tie(0); int testcase = 1;//cin >> testcase; while(testcase--)solve(); } /* obs1 : almadıklarımdan ilk x tanesini kesin alcam dp[i][j] -> şimdiye kadar kaç tane aldım */
#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...