Legendary_45's blog

By Legendary_45, history, 18 hours ago, In English

https://codeforces.me/problemset/problem/1659/C

include <bits/stdc++.h>

/*.......................code by LegendARY...............................*/ using namespace std; using ll = long long; // my recusive solution ll Min_dist(ll capital,ll n,ll conq,ll a,ll b,vector&arr){ if(conq >= n-1){ // last wale to direct return b*(arr[n-1]-capital); } // c1 ko don't change, // c1 ko change kr do: take out the minimum; return min(b*abs(capital-arr[conq])+Min_dist(capital,n,conq+1,a,b,arr) ,a*abs(capital-arr[conq])+b*abs(arr[conq]-arr[conq+1])+Min_dist(arr[conq],n,conq+1,a,b,arr));
} //cout<<fixed<<setprecision(6) <<vv; void MYFUN(){ ll n,a,b; cin>>n>>a>>b; vectorarr(n); for(auto &it:arr) cin>>it; ll c1 =0; cout<<Min_dist(0,n,1,a,b,arr)+b*(arr[0])<<endl; } // u had to choose these three

int main(){ ll n; cin>>n; while(n--)MYFUN(); }

Full text and comments »

  • Vote: I like it
  • -8
  • Vote: I do not like it

By Legendary_45, history, 5 months ago, In English

Is it good to use unordered map for every dp problem as it could be more memory efficient in comparison to vector in c++

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By Legendary_45, history, 9 months ago, In English

https://codeforces.me/blog/entry/129992 in this editorial , the editorial of c, what if the no bad exist, like n = 2, m=2; a == (3 3 5 5 1) b == (5 5 3 3 2) i will not consider the 1,2 as it is at the m+n+1 index so before that no bad exist, am i wrong ?

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By Legendary_45, history, 9 months ago, In English
  • Vote: I like it
  • -2
  • Vote: I do not like it