#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main(){
    int n,d,b=INT_MAX,c=0,ans=0;
    cin>>n>>d;
    for(int i=1;i<n;i++){
        int dat;
        cin>>dat;
        v.push_back(dat);
    }
    for(int i=1;i<n;i++){
        int a;
        cin>>a;
        b=min(a,b);
        while(c<v[i-1]){c+=d;ans+=b;}
        c-=v[i-1];
    }
    cout<<ans;
}

0 comments

No comments so far...

Information

ID
9095
Time
1000ms
Memory
256MiB
Difficulty
6
Tags
# Submissions
14
Accepted
3
Uploaded By