//NiceDuck
#include "bits/stdc++.h"
typedef long long ll;
using namespace std;
#define FILE "000"
#define foru(i,a,b) for(int i=(int)(a); i<=(int)(b); ++i)
#define ford(i,a,b) for(int i=(int)(a); i>=(int)(b); --i)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define MOD 1000000007
#define el "\n"

const int MAX=500005;
int n,k,h[MAX],low[MAX],high[MAX];
ll t[MAX],prefix[MAX];

void pre()
{
    stack<int> st;
    foru(i,1,n)
    {
        low[i]=1;
        while(!st.empty() && h[st.top()]<h[i]) st.pop();
        if(!st.empty()) low[i]=st.top();
        st.push(i);
    }
    while(!st.empty()) st.pop();
    ford(i,n,1)
    {
        high[i]=n;
        while(!st.empty() && h[st.top()]<h[i]) st.pop();
        if(!st.empty()) high[i]=st.top();
        st.push(i);
    }
    while(!st.empty()) st.pop();   
}

int maxR[MAX];
bool check(ll x)
{
    memset(maxR,0,sizeof(maxR));
    int l=1,r=1;
    foru(i,1,n)
    {
        while(l<i && prefix[i]-prefix[l]>x)
        {
            ++l;
        }
        while(r<=n && prefix[r]-prefix[i]<=x)
        {
            ++r;
        }
        int L=max(l,low[i]), R=min(r-1,high[i]);
        maxR[L]=max(maxR[L],R);
    }
    int need=1,cnt=0,i=1;
    while(need<=n)
    {
        int mx=0;
        while(i<=need)
        {
            mx=max(mx,maxR[i]);
            ++i;
        }
        if(mx==0) break;
        ++cnt;
        need=mx+1;
    }
    return need>n && cnt<=k;
}

int main()
{
    fastio
    #ifndef ONLINE_JUDGE
    freopen(FILE ".inp","r",stdin);
    freopen(FILE ".out","w",stdout);
    #endif // ONLINE_JUDGE
    
    cin>>n>>k;
    foru(i,1,n) cin>>h[i];
    foru(i,2,n) 
    {
        cin>>t[i];
        prefix[i]=prefix[i-1]+t[i];
    }
    pre();
    ll ans=-1,l=1,r=prefix[n];
    while(l<=r)
    {
        ll m=(l+r)>>1;
        if(check(m))
        {
            ans=m;
            r=m-1;
        }
        else l=m+1;
    }
    cout<<ans;
    
    return 0;
}