Submission #1233224

#TimeUsernameProblemLanguageResultExecution timeMemory
1233224ByeWorldLet's Win the Election (JOI22_ho_t3)C++20
10 / 100
1208 ms8488 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3", "Ofast") #define int long long #define ll long long #define se second #define fi first #define pb push_back #define lf (id<<1) #define rg ((id<<1)|1) #define md ((l+r)>>1) #define ld long double using namespace std; typedef pair<int,int> pii; typedef pair<pii,pii> ipii; const int MAXN = 5e5+10; const int MAXA = 5e5+10; const int SQRT = 450; const ld INF = 1e16; const int MOD = 1e9+7; const int LOG = 60; int sum(int a, int b){ return (a+MOD+b)%MOD; } void chsum(int &a, int b){ a = sum(a,b); } int mul(int a, int b){ return (a*b)%MOD; } void chmul(int &a, int b){ a = mul(a,b); } void chmn(auto &a, auto b){ a = min(a, b); } void chmx(auto &a, auto b){ a = max(a, b); } vector<int> dx = {0, 0, -1, 1}; vector<int> dy = {1, -1, 0, 0}; int n, need, a[MAXN], b[MAXN]; ld dp[3][510][510]; signed main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n>>need; vector<pii> vec; vec.pb({-1,-1}); for(int i=1; i<=n; i++){ cin>>a[i]>>b[i]; if(b[i]==-1) b[i] = INF; vec.pb({b[i], a[i]}); } sort(vec.begin(), vec.end()); for(int i=1; i<=n; i++) a[i] = vec[i].se, b[i] = vec[i].fi; for(int i=0; i<=1; i++) for(int j=0; j<=n; j++) for(int k=0; k<=need; k++) dp[i][j][k] = INF; dp[0][0][0] = 0; for(int i=1; i<=n; i++){ // cout << a[i] << ' ' << b[i] << " b\n"; for(int j=0; j<=need; j++){ // ambil speed nya for(int k=j; k<=need; k++){ dp[i%2][j][k] = dp[1-i%2][j][k]; if(k!=0 && j!=0 && b[i]!=INF) // ambil b chmn(dp[i%2][j][k], dp[1-i%2][j-1][k-1] + (ld)b[i]/j); if(k!=0) // ambil a chmn(dp[i%2][j][k], dp[1-i%2][j][k-1] + (ld)a[i]/(j+1) ); } } for(int j=0; j<=need; j++) // ambil speed nya for(int k=j; k<=need; k++) dp[1-i%2][j][k] = INF; // cout << dp[2][1][2] << " pp\n\n"; } ld ANS = INF; for(int j=0; j<=n; j++) chmn(ANS, dp[n%2][j][need]); cout << fixed << setprecision(5) << 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...