Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define nl "\n"
- #define fi first
- #define se second
- #define pb push_back
- #define ll long long
- #define ull unsigned ll
- #define RV return void
- #define sz(x) int(x.size())
- #define all(v) v.begin(), v.end()
- #define rall(v) v.rbegin(), v.rend()
- #define fixed(n) fixed << setprecision(n)
- #define cin(v) for (auto&i:v) cin >> i;
- #define cout(v) for (auto&i:v) cout << i << " ";
- #define clr(memo, x) memset(memo, x, sizeof memo)
- #define FastCode ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
- void Zainab(){
- // #ifndef ONLINE_JUDGE
- freopen("hobz.in", "r", stdin);
- // freopen("longpath.out", "w", stdout);
- // #endif
- }
- ll n;
- vector < ll > v ,dp;
- const ll inf = 1e15;
- ll rec(ll idx ) {
- if(idx >= n) return (idx == n ? 0 : inf);
- ll & ret = dp[idx];
- if(~ret)
- return ret ;
- ret =inf;
- for(ll i =1 ; i <= min( 7ll , n-idx ) ; ++i){
- ret = min(ret , 1ll * v[idx] * i + rec(idx+i));
- }
- return ret;
- }
- void myCode( int test){
- cin >> n;
- v.assign(n,0);
- cin(v);
- dp.assign(n+1 , -1);
- cout << rec(0) << nl;
- // for(int i =0 ; i < n ; i++) cout << i << " " << dp[i] << nl;
- }
- int main(){
- FastCode ;
- int testCase=1;
- // cin >> testCase ;
- for(int i=1 ; i<= testCase ; i++)
- myCode(i);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement