Submission #1195575

#TimeUsernameProblemLanguageResultExecution timeMemory
1195575JuanJLLet's Win the Election (JOI22_ho_t3)C++20
0 / 100
1323 ms910760 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define fst first #define snd second #define pb push_back #define forn(i,a,b) for(int i = a; i < b; i++) #define ALL(x) x.begin(),x.end() #define SZ(x) (int)x.size() #define mset(a,v) memset((a),(v),sizeof(a)) #define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define dbg(v) cout<<"Line("<<__LINE__<<"): "<<#v<<" = "<<v<<'\n'; #define pi pair<int,int> #define pll pair<ll,ll> typedef long long ll; using namespace std; using namespace __gnu_pbds; typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set; typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_multiset; const int MAXN = 501; long double dp[MAXN][MAXN][MAXN]; bool vis[MAXN][MAXN][MAXN]; ll n,k; vector<pair<long double,long double>> s; long double f(ll x, ll y, long double z){ //cout<<x<<" "<<y<<" "<<z<<'\n'; long double &res = dp[x][y][(ll)z]; //cout<<res<<" "<<vis[x][y][(ll)z]<<'\n'; if(vis[x][y][(ll)z]) return res; if(y==k) return (long double)0; if(x==n) return (long double)10000000000000000; vis[x][y][(ll)z]=true; //cout<<x<<" "<<y<<" "<<z<<'\n'; res=0; res=f(x+1,y,z); res=min(res,f(x+1,y+1,z)+s[x].snd/z); if(s[x].fst>0)res=min(res,f(x+1,y+1,z+1)+s[x].fst/z); //cout<<x<<" "<<y<<" "<<z<<" ->>>> "<<res<<'\n'; return res; } int main(){FIN; cin>>n>>k; s.clear(); s.resize(n); forn(i,0,n){ cin>>s[i].snd>>s[i].fst; if(s[i].fst==-1){ s[i].fst=(long double)10000000000000000; }} sort(ALL(s)); forn(i,0,MAXN) forn(j,0,MAXN) forn(h,0,MAXN) vis[i][j][h]=false; cout<<"llego\n"; cout<<fixed<<setprecision(15)<<f(0,0,1)<<'\n'; return 0; }
#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...