#include<iostream>
#include<cstring>
#include<cstdio>
#include<queue>
using namespace std ;
const int maxn=200000+20 ;
typedef long long ll ;
ll A[maxn],B[maxn] ;
int N,K;
ll l=0,r=1999989999999*10,mid ;
ll ans=-1 ;
struct node{
	ll t ;
	ll a,b ;
	bool operator < (const node x)const{
		if(x.t!=t) return t>x.t ;
		if(x.b!=b) return b<x.b ;
		return a>x.a ;
	}
};
priority_queue<node> q ;
inline bool check(ll charger){
	while(!q.empty()) q.pop() ;
	node temp ;
	for(int i=1;i<=N;i++){
		if(A[i]/B[i]>=K) continue ;
			temp.a=A[i] ;
			temp.b=B[i] ;
			temp.t=A[i]/B[i] ;
			q.push(temp) ;
	}
	if(q.empty()) return true ;
	for(int i=0;i<K;i++){
		temp=q.top(); q.pop() ;
		if(temp.t<i) return false ;
		if(((temp.a+charger)/temp.b)<K){
			node ttemp ;
			ttemp.a=temp.a+charger ;
			ttemp.b=temp.b ;
			ttemp.t=(temp.a+charger)/temp.b ;
			q.push(ttemp) ;
		}
		if(q.empty()) return true ;
	}
	return true ;
}
int main(){
	scanf("%d%d",&N,&K) ;
	for(int i=1;i<=N;i++) scanf("%lld",&A[i]) ;
	for(int i=1;i<=N;i++) scanf("%lld",&B[i]) ;
	while(l<=r){
		mid=(l+r)>>1 ;
		if(check(mid)){
			r=mid-1 ;
			ans=mid ;
		}
		else l=mid+1 ;
	}
	printf("%lld\n",ans) ;
	return 0 ;
}


#include<bits/stdc++.h>
#define maxn 200005
#define ll long long
using namespace std;
int N,K;
ll a[maxn],b[maxn];
struct node
{
	ll a,b;
	node(ll a=0,ll b=0):a(a),b(b){}
};
vector<node>adj[maxn];
bool check(ll x)
{
	for(int i=0;i<K;i++)
		adj[i].clear();
	for(int i=1;i<=N;i++)
	{
		if(a[i]/b[i]+1<K)
			adj[a[i]/b[i]+1].push_back(node(a[i],b[i]));
	}
	int p=0;
	for(int cur=0;cur<K;cur++)
	{
		while(p<K&&adj[p].empty())
			p++;
		if(p==K)return true;
		if(p==cur&&adj[p].size()>1)return false;

		node u=adj[p].back();
		adj[p].pop_back();
		if(u.a/u.b<cur)return false;

		u.a+=x;
		if(u.a/u.b<cur)return false;
		if(u.a/u.b+1<K)adj[u.a/u.b+1].push_back(u);
	}
	return true;
}
int main()
{
	scanf("%d%d",&N,&K);
	for(int i=1;i<=N;i++)
		scanf("%lld",&a[i]);
	for(int i=1;i<=N;i++)
		scanf("%lld",&b[i]);
	ll l=0,r=2e12,mid;
	if(!check(r))
	{
		printf("-1\n");
		return 0;
	}
	while(l<r)
	{
		mid=(l+r)>>1;
		if(check(mid))r=mid;
		else l=mid+1;
	}
	printf("%lld\n",r);
	return 0;
}


#include<bits/stdc++.h>
#define fr(i,x,y) for(int i=x;i<=y;++i)
#define rf(i,x,y) for(int i=x;i>=y;--i)
#define LL long long
using namespace std;
const int N=2e5+10;
struct data{
	LL a,b,t;
	bool operator < (const data &C ) const {
		return t>C.t;
	}
}w[N];
int n,k;
priority_queue<data>q;

template <class T>
void read(T &x){
	char ch=getchar();x=0;
	for(;ch<'0'||ch>'9';ch=getchar()) ;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch^48);
}

void fail(){
	puts("-1");
	exit(0);
}

bool check(LL x){
	while(!q.empty()) q.pop();
	fr(i,1,n) q.push(w[i]);
	fr(i,1,k-1){
		data h=q.top();q.pop();
		h.a+=x,h.t+=h.a/h.b;
		h.a%=h.b;
		q.push(h);
		if(q.top().t<i) {
		//	printf("false%d\n",i);
			return false;
		}
	}
	return true;
}

int main(){
	read(n),read(k);
	fr(i,1,n) read(w[i].a);
	fr(i,1,n) read(w[i].b),w[i].t=w[i].a/w[i].b,w[i].a%=w[i].b;
	LL l=0,r=1e13,ans=-1;
	while(l<=r){
		//printf("%lld %lld\n",l,r);
		LL mid=(l+r)>>1;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	//printf("%d\n",check(4));
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#define fr(i,x,y) for(int i=x;i<=y;++i)
#define rf(i,x,y) for(int i=x;i>=y;--i)
#define LL long long
using namespace std;
const int N=2e5+10;
struct data{
	LL a,b,t;
	bool operator < (const data &C ) const {
		return t>C.t;
	}
}w[N];
int n,k;
priority_queue<data>q;

template <class T>
void read(T &x){
	char ch=getchar();x=0;
	for(;ch<'0'||ch>'9';ch=getchar()) ;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch^48);
}

void fail(){
	puts("-1");
	exit(0);
}

bool check(LL x){
	q=priority_queue<data>();
	fr(i,1,n) q.push(w[i]);
	fr(i,1,k){
		data h=q.top();q.pop();
		if(h.t<(i-1)) return false;
		h.a+=x,h.t+=h.a/h.b;
		h.a-=(h.a/h.b)*h.b;
		q.push(h);
	}
	return true;
}

int main(){
	read(n),read(k);
	fr(i,1,n) read(w[i].a);
	fr(i,1,n) read(w[i].b),w[i].t=w[i].a/w[i].b,w[i].a%=w[i].b;
	LL l=0,r=1e13,ans=-1;
	while(l<=r){
		LL mid=(l+r)>>1;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#define fr(i,x,y) for(int i=x;i<=y;++i)
#define rf(i,x,y) for(int i=x;i>=y;--i)
#define LL long long
using namespace std;
const int N=2e5+10;
struct data{
	LL a,b,t;
	bool operator < (const data &C ) const {
		return t>C.t;
	}
}w[N];
int n,k;
priority_queue<data>q;

template <class T>
void read(T &x){
	char ch=getchar();x=0;
	for(;ch<'0'||ch>'9';ch=getchar()) ;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch^48);
}

void fail(){
	puts("-1");
	exit(0);
}

bool check(LL x){
	while(!q.empty()) q.pop();
	fr(i,1,n) q.push(w[i]);
	fr(i,1,k){
		data h=q.top();q.pop();
		if(h.t<(i-1)) return false;
		h.a+=x,h.t+=h.a/h.b;
		h.a-=(h.a/h.b)*h.b;
		q.push(h);
	}
	return true;
}

int main(){
	read(n),read(k);
	fr(i,1,n) read(w[i].a);
	fr(i,1,n) read(w[i].b),w[i].t=w[i].a/w[i].b,w[i].a%=w[i].b;
	LL l=0,r=1e12,ans=-1;
	while(l<=r){
		//printf("%lld %lld\n",l,r);
		LL mid=(l+r)>>1;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	//printf("%d\n",check(4));
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#define fr(i,x,y) for(int i=x;i<=y;++i)
#define rf(i,x,y) for(int i=x;i>=y;--i)
#define LL long long
using namespace std;
const int N=2e5+10;
struct data{
	LL a,b,t;
	bool operator < (const data &C ) const {
		return t>C.t;
	}
}w[N];
int n,k;
priority_queue<data>q;

template <class T>
void read(T &x){
	char ch=getchar();x=0;
	for(;ch<'0'||ch>'9';ch=getchar()) ;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch^48);
}

void fail(){
	puts("-1");
	exit(0);
}

bool check(LL x){
	q=priority_queue<data>();
	fr(i,1,n) q.push(w[i]);
	fr(i,1,k){
		data h=q.top();q.pop();
		if(h.t<(i-1)) return false;
		h.a+=x,h.t+=h.a/h.b;
		h.a-=(h.a/h.b)*h.b;
		q.push(h);
	}
	return true;
}

int main(){
	read(n),read(k);
	fr(i,1,n) read(w[i].a);
	fr(i,1,n) read(w[i].b),w[i].t=w[i].a/w[i].b,w[i].a%=w[i].b;
	LL l=0,r=1e15,ans=-1;
	while(l<=r){
		LL mid=(l+r)>>1;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#define fr(i,x,y) for(int i=x;i<=y;++i)
#define rf(i,x,y) for(int i=x;i>=y;--i)
#define LL long long
using namespace std;
const int N=2e5+10;
struct data{
	LL a,b,t;
	bool operator < (const data &C ) const {
		return t>C.t;
	}
}w[N];
int n,k;
priority_queue<data>q;

template <class T>
void read(T &x){
	char ch=getchar();x=0;
	for(;ch<'0'||ch>'9';ch=getchar()) ;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch^48);
}

void fail(){
	puts("-1");
	exit(0);
}

bool check(LL x){
	while(!q.empty()) q.pop();
	fr(i,1,n) q.push(w[i]);
	fr(i,1,k-1){
		data h=q.top();q.pop();
		h.a+=x,h.t=h.a/h.b;
		q.push(h);
		if(q.top().t<i) {
		//	printf("false%d\n",i);
			return false;
		}
	}
	return true;
}

int main(){
	read(n),read(k);
	fr(i,1,n) read(w[i].a);
	fr(i,1,n) read(w[i].b),w[i].t=w[i].a/w[i].b;
	LL l=0,r=1e12,ans=-1;
	while(l<=r){
		//printf("%lld %lld\n",l,r);
		LL mid=(l+r)>>1;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	//printf("%d\n",check(4));
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#define fr(i,x,y) for(int i=x;i<=y;++i)
#define rf(i,x,y) for(int i=x;i>=y;--i)
#define LL long long
using namespace std;
const int N=2e5+10;
struct data{
	LL a,b,t;
	bool operator < (const data &C ) const {
		return t>C.t;
	}
}w[N];
int n,k;
priority_queue<data>q;

template <class T>
void read(T &x){
	char ch=getchar();x=0;
	for(;ch<'0'||ch>'9';ch=getchar()) ;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch^48);
}

void fail(){
	puts("-1");
	exit(0);
}

bool check(LL x){
	while(!q.empty()) q.pop();
	fr(i,1,n) q.push(w[i]);
	fr(i,1,k-1){
		data h=q.top();q.pop();
		h.a+=x,h.t+=h.a/h.b;
		h.a%=h.b;
		q.push(h);
		if(q.top().t<i) {
		//	printf("false%d\n",i);
			return false;
		}
	}
	return true;
}

int main(){
	read(n),read(k);
	fr(i,1,n) read(w[i].a);
	fr(i,1,n) read(w[i].b),w[i].t=w[i].a/w[i].b,w[i].a%=w[i].b;
	LL l=0,r=1e12,ans=-1;
	while(l<=r){
		//printf("%lld %lld\n",l,r);
		LL mid=(l+r)>>1;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	//printf("%d\n",check(4));
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#define fr(i,x,y) for(int i=x;i<=y;++i)
#define rf(i,x,y) for(int i=x;i>=y;--i)
#define LL long long
using namespace std;
const int N=2e5+10;
struct data{
	LL a,b,t;
	bool operator < (const data &C ) const {
		return t>C.t;
	}
}w[N];
int n,k;
priority_queue<data>q;

template <class T>
void read(T &x){
	char ch=getchar();x=0;
	for(;ch<'0'||ch>'9';ch=getchar()) ;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch^48);
}

void fail(){
	puts("-1");
	exit(0);
}

bool check(LL x){
	while(!q.empty()) q.pop();
	fr(i,1,n) q.push(w[i]);
	fr(i,1,k-1){
		data h=q.top();q.pop();
		h.a+=x,h.t=h.a/h.b;
		q.push(h);
		if(q.top().t<i) {
		//	printf("false%d\n",i);
			return false;
		}
	}
	return true;
}

int main(){
	read(n),read(k);
	fr(i,1,n) read(w[i].a);
	fr(i,1,n) read(w[i].b),w[i].t=w[i].a/w[i].b;
	LL l=0,r=1e11,ans=-1;
	while(l<=r){
		//printf("%lld %lld\n",l,r);
		LL mid=(l+r)>>1;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	//printf("%d\n",check(4));
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#define fr(i,x,y) for(int i=x;i<=y;++i)
#define rf(i,x,y) for(int i=x;i>=y;--i)
#define LL long long
using namespace std;
const int N=2e5+10;
struct data{
	LL a,b,t;
	bool operator < (const data &C ) const {
		return t>C.t;
	}
}w[N];
int n,k;
priority_queue<data>q;

template <class T>
void read(T &x){
	char ch=getchar();x=0;
	for(;ch<'0'||ch>'9';ch=getchar()) ;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch^48);
}

void fail(){
	puts("-1");
	exit(0);
}

bool check(LL x){
	q=priority_queue<data>();
	fr(i,1,n) q.push(w[i]);
	fr(i,1,k){
		data h=q.top();q.pop();
		if(h.t<(i-1)) return false;
		h.a+=x,h.t+=h.a/h.b;
		h.a-=(h.a/h.b)*h.b;
		q.push(h);
	}
	return true;
}

int main(){
	read(n),read(k);
	fr(i,1,n) read(w[i].a);
	fr(i,1,n) read(w[i].b),w[i].t=w[i].a/w[i].b,w[i].a%=w[i].b;
	LL l=0,r=1e12,ans=-1;
	while(l<=r){
		LL mid=(l+r)>>1;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#define fr(i,x,y) for(int i=x;i<=y;++i)
#define rf(i,x,y) for(int i=x;i>=y;--i)
#define LL long long
using namespace std;
const int N=2e5+10;
struct data{
	LL a,b,t;
	bool operator < (const data &C ) const {
		return t>C.t;
	}
}w[N];
int n,k;
priority_queue<data>q;

template <class T>
void read(T &x){
	char ch=getchar();x=0;
	for(;ch<'0'||ch>'9';ch=getchar()) ;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch^48);
}

void fail(){
	puts("-1");
	exit(0);
}

bool check(LL x){
	while(!q.empty()) q.pop();
	fr(i,1,n) q.push(w[i]);
	fr(i,1,k-1){
		data h=q.top();q.pop();
		h.a+=x,h.t=h.a/h.b;
		q.push(h);
		if(q.top().t<i) {
		//	printf("false%d\n",i);
			return false;
		}
	}
	return true;
}

int main(){
	read(n),read(k);
	fr(i,1,n) read(w[i].a);
	fr(i,1,n) read(w[i].b),w[i].t=w[i].a/w[i].b;
	LL l=0,r=1e7,ans=-1;
	while(l<=r){
		//printf("%lld %lld\n",l,r);
		LL mid=(l+r)>>1;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	//printf("%d\n",check(4));
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>
#define fr(i,x,y) for(int i=x;i<=y;++i)
#define rf(i,x,y) for(int i=x;i>=y;--i)
#define LL long long
using namespace std;
const int N=2e5+10;
struct data{
	LL a,b,t;
	bool operator < (const data &C ) const {
		return t>C.t;
	}
}w[N];
int n,k;
priority_queue<data>q;

template <class T>
void read(T &x){
	char ch=getchar();x=0;
	for(;ch<'0'||ch>'9';ch=getchar()) ;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+(ch^48);
}

void fail(){
	puts("-1");
	exit(0);
}

bool check(LL x){
	while(!q.empty()) q.pop();
	fr(i,1,n) q.push(w[i]);
	fr(i,1,k-1){
		data h=q.top();q.pop();
		h.a+=x,h.t=h.a/h.b;
		q.push(h);
		if(q.top().t<i) {
		//	printf("false%d\n",i);
			return false;
		}
	}
	return true;
}

int main(){
	read(n),read(k);
	fr(i,1,n) read(w[i].a);
	fr(i,1,n) read(w[i].b),w[i].t=w[i].a/w[i].b;
	LL l=0,r=1e18,ans=-1;
	while(l<=r){
		//printf("%lld %lld\n",l,r);
		LL mid=(l+r)>>1;
		if(check(mid)) ans=mid,r=mid-1;
		else l=mid+1;
	}
	//printf("%d\n",check(5));
	printf("%lld\n",ans);
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

namespace zzc
{
	const int maxn = 2e5+5;
	long long a[maxn],b[maxn];
	int n,k;
	long long ans=-1,l,r,mid;

	struct node
	{
		long long a,b,tim;
		bool operator <(const node &x)const
		{
			return tim==x.tim?b==x.b?a>x.a:b>x.b:tim>x.tim;
		}
	};
	priority_queue<node> q;

	bool check(long long x)
	{
		while(!q.empty()) q.pop();
		for(int i=1;i<=n;i++)
		{
			if(a[i]/b[i]>=k) continue;
			q.push((node){a[i],b[i],a[i]/b[i]});
		}
		if(q.empty()) return true;
		for(int i=0;i<k;i++)
		{
			node tmp=q.top();q.pop();
			if(tmp.tim<i) return false;
			if((tmp.a+x)/tmp.b<=k)
			{
				q.push((node){tmp.a+x,tmp.b,(tmp.a+x)/tmp.b});
			}
			if(q.empty()) return true;
		}
		return true;
	}

	void work()
	{
		scanf("%d%d",&n,&k);
		for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
		for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
		l=0;r=0x7fffffffff;
		while(l<=r)
		{
			mid=(l+r)>>1;
			if(check(mid))
			{
				ans=mid;
				r=mid-1;
			}
			else l=mid+1;
		}
		printf("%lld\n",ans);
	}

}

int main()
{
	zzc::work();
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

namespace zzc
{
	const int maxn = 2e5+5;
	long long a[maxn],b[maxn];
	long long n,k;
	long long ans=-1,l,r,mid;

	long long read()
	{
		long long x=0,f=1;
		char ch=getchar();
		while(!isdigit(ch))
		{
			if(ch=='-') f=-1;
			ch=getchar();
		}
		while(isdigit(ch))
		{
			x=(x<<1)+(x<<3)+ch-48;
			ch=getchar();
		}
		return f*x;
	}

	struct node
	{
		long long a,b,tim;
		bool operator <(const node &x)const
		{
			return tim==x.tim?b==x.b?a>x.a:b>x.b:tim>x.tim;
		}
	};
	priority_queue<node> q;

	bool check(long long x)
	{
		while(!q.empty()) q.pop();
		for(int i=1;i<=n;i++)
		{
			if(a[i]/b[i]>=k) continue;
			q.push((node){a[i],b[i],a[i]/b[i]});
		}
		if(q.empty()) return true;
		for(int i=0;i<k;i++)
		{
			node tmp=q.top();q.pop();
			if(tmp.tim<i) return false;
			if((tmp.a+x)/tmp.b<=k)
			{
				q.push((node){tmp.a+x,tmp.b,(tmp.a+x)/tmp.b});
			}
			if(q.empty()) return true;
		}
		return true;
	}

	void work()
	{
		scanf("%lld%lld",&n,&k);
		//for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
		//for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
		for(int i=1;i<=n;i++) a[i]=read();
		for(int i=1;i<=n;i++) b[i]=read();
		l=0;r=1e15+5;
		while(l<=r)
		{
			mid=(l+r)>>1;
			if(check(mid))
			{
				ans=mid;
				r=mid-1;
			}
			else l=mid+1;
		}
		printf("%lld\n",ans);
	}

}

int main()
{
	zzc::work();
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

namespace zzc
{
	const int maxn = 2e5+5;
	long long a[maxn],b[maxn];
	int n,k;
	long long ans=-1,l,r,mid;

	struct node
	{
		long long a,b,tim;
		bool operator <(const node &x)const
		{
			return tim==x.tim?b==x.b?a>x.a:b>x.b:tim>x.tim;
		}
	};
	priority_queue<node> q;

	bool check(long long x)
	{
		while(!q.empty()) q.pop();
		for(int i=1;i<=n;i++)
		{
			if(a[i]/b[i]>=k) continue;
			q.push((node){a[i],b[i],a[i]/b[i]});
		}
		if(q.empty()) return true;
		for(int i=0;i<k;i++)
		{
			node tmp=q.top();q.pop();
			if(tmp.tim<i) return false;
			if((tmp.a+x)/tmp.b<=k)
			{
				q.push((node){tmp.a+x,tmp.b,(tmp.a+x)/tmp.b});
			}
			if(q.empty()) return true;
		}
		return true;
	}

	void work()
	{
		scanf("%d%d",&n,&k);
		for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
		for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
		l=0;r=1e12+5;
		while(l<=r)
		{
			mid=(l+r)>>1;
			if(check(mid))
			{
				ans=mid;
				r=mid-1;
			}
			else l=mid+1;
		}
		printf("%lld\n",ans);
	}

}

int main()
{
	zzc::work();
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

namespace zzc
{
	const int maxn = 2e5+5;
	long long a[maxn],b[maxn];
	long long n,k;
	long long ans=-1,l,r,mid;

	long long read()
	{
		long long x=0,f=1;
		char ch=getchar();
		while(!isdigit(ch))
		{
			if(ch=='-') f=-1;
			ch=getchar();
		}
		while(isdigit(ch))
		{
			x=(x<<1)+(x<<3)+ch-48;
			ch=getchar();
		}
		return f*x;
	}

	struct node
	{
		long long a,b,tim;
		bool operator <(const node &x)const
		{
			return tim==x.tim?b==x.b?a>x.a:b>x.b:tim>x.tim;
		}
	};
	priority_queue<node> q;

	bool check(long long x)
	{
		while(!q.empty()) q.pop();
		for(int i=1;i<=n;i++)
		{
			if(a[i]/b[i]>=k) continue;
			q.push((node){a[i],b[i],a[i]/b[i]});
		}
		if(q.empty()) return true;
		for(int i=0;i<k;i++)
		{
			node tmp=q.top();q.pop();
			if(tmp.tim<i) return false;
			if((tmp.a+x)/tmp.b<=k)
			{
				q.push((node){tmp.a+x,tmp.b,(tmp.a+x)/tmp.b});
			}
			if(q.empty()) return true;
		}
		return true;
	}

	void work()
	{
		scanf("%lld%lld",&n,&k);
		//for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
		//for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
		for(int i=1;i<=n;i++) a[i]=read();
		for(int i=1;i<=n;i++) b[i]=read();
		l=0;r=1e13+5;
		while(l<=r)
		{
			mid=(l+r)>>1;
			if(check(mid))
			{
				ans=mid;
				r=mid-1;
			}
			else l=mid+1;
		}
		printf("%lld\n",ans);
	}

}

int main()
{
	zzc::work();
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

namespace zzc
{
	const int maxn = 2e5+5;
	long long a[maxn],b[maxn];
	int n,k;
	long long ans=-1,l,r,mid;

	struct node
	{
		long long a,b,tim;
		bool operator <(const node &x)const
		{
			return tim==x.tim?b==x.b?a>x.a:b>x.b:tim>x.tim;
		}
	};
	priority_queue<node> q;

	bool check(long long x)
	{
		while(!q.empty()) q.pop();
		for(int i=1;i<=n;i++)
		{
			if(a[i]/b[i]>=k) continue;
			q.push((node){a[i],b[i],a[i]/b[i]});
		}
		if(q.empty()) return true;
		for(int i=0;i<k;i++)
		{
			node tmp=q.top();q.pop();
			if(tmp.tim<i) return false;
			if((tmp.a+x)/tmp.b<=k)
			{
				q.push((node){tmp.a+x,tmp.b,(tmp.a+x)/tmp.b});
			}
			if(q.empty()) return true;
		}
		return true;
	}

	void work()
	{
		scanf("%d%d",&n,&k);
		for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
		for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
		l=0;r=0x3f3f3f3f;
		while(l<=r)
		{
			mid=(l+r)>>1;
			if(check(mid))
			{
				ans=mid;
				r=mid-1;
			}
			else l=mid+1;
		}
		printf("%lld\n",ans);
	}

}

int main()
{
	zzc::work();
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

namespace zzc
{
	const int maxn = 2e5+5;
	long long a[maxn],b[maxn];
	int n,k;
	long long ans=-1,l,r,mid;

	struct node
	{
		long long a,b,tim;
		bool operator <(const node &x)const
		{
			return tim==x.tim?b==x.b?a>x.a:b>x.b:tim>x.tim;
		}
	};
	priority_queue<node> q;

	bool check(long long x)
	{
		while(!q.empty()) q.pop();
		for(int i=1;i<=n;i++)
		{
			if(a[i]/b[i]>=k) continue;
			q.push((node){a[i],b[i],a[i]/b[i]});
		}
		if(q.empty()) return true;
		for(int i=0;i<k;i++)
		{
			node tmp=q.top();q.pop();
			if(tmp.tim<i) return false;
			if((tmp.a+x)/tmp.b<=k)
			{
				q.push((node){tmp.a+x,tmp.b,(tmp.a+x)/tmp.b});
			}
			if(q.empty()) return true;
		}
		return true;
	}

	void work()
	{
		scanf("%d%d",&n,&k);
		for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
		for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
		l=0;r=0x7ffffffffffff;
		while(l<=r)
		{
			mid=(l+r)>>1;
			if(check(mid))
			{
				ans=mid;
				r=mid-1;
			}
			else l=mid+1;
		}
		printf("%lld\n",ans);
	}

}

int main()
{
	zzc::work();
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

namespace zzc
{
	const int maxn = 2e5+5;
	long long a[maxn],b[maxn];
	int n,k;
	long long ans=-1,l,r,mid;

	struct node
	{
		long long a,b,tim;
		bool operator <(const node &x)const
		{
			return tim==x.tim?b==x.b?a>x.a:b>x.b:tim>x.tim;
		}
	};
	priority_queue<node> q;

	bool check(long long x)
	{
		while(!q.empty()) q.pop();
		for(int i=1;i<=n;i++)
		{
			if(a[i]/b[i]>=k) continue;
			q.push((node){a[i],b[i],a[i]/b[i]});
		}
		if(q.empty()) return true;
		for(int i=0;i<k;i++)
		{
			node tmp=q.top();q.pop();
			if(tmp.tim<i) return false;
			if((tmp.a+x)/tmp.b<=k)
			{
				q.push((node){tmp.a+x,tmp.b,(tmp.a+x)/tmp.b});
			}
			if(q.empty()) return true;
		}
		return true;
	}

	void work()
	{
		scanf("%d%d",&n,&k);
		for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
		for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
		l=0;r=1e15+5;
		while(l<=r)
		{
			mid=(l+r)>>1;
			if(check(mid))
			{
				ans=mid;
				r=mid-1;
			}
			else l=mid+1;
		}
		printf("%lld\n",ans);
	}

}

int main()
{
	zzc::work();
	return 0;
}


#include<bits/stdc++.h>

using namespace std;

namespace zzc
{
	const int maxn = 2e5+5;
	long long a[maxn],b[maxn];
	int n,k;
	long long ans=-1,l,r,mid;

	struct node
	{
		long long a,b,tim;
		bool operator <(const node &x)const
		{
			return tim==x.tim?b==x.b?a>x.a:b>x.b:tim>x.tim;
		}
	};
	priority_queue<node> q;

	bool check(long long x)
	{
		while(!q.empty()) q.pop();
		for(int i=1;i<=n;i++)
		{
			if(a[i]/b[i]>=k) continue;
			q.push((node){a[i],b[i],a[i]/b[i]});
		}
		if(q.empty()) return true;
		for(int i=0;i<k;i++)
		{
			node tmp=q.top();q.pop();
			if(tmp.tim<i) return false;
			if((tmp.a+x)/tmp.b<=k)
			{
				q.push((node){tmp.a+x,tmp.b,(tmp.a+x)/tmp.b});
			}
			if(q.empty()) return true;
		}
		return true;
	}

	void work()
	{
		scanf("%d%d",&n,&k);
		for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
		for(int i=1;i<=n;i++) scanf("%lld",&b[i]);
		l=1;r=0x3f3f3f3f;
		while(l<=r)
		{
			mid=(l+r)>>1;
			if(check(mid))
			{
				ans=mid;
				r=mid-1;
			}
			else l=mid+1;
		}
		printf("%lld\n",ans);
	}

}

int main()
{
	zzc::work();
	return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/

ll n,k;
ll a[200005],b[200005];
ll check(ll x){
	priority_queue<pair<ll,pll > >pq;
	for(ll i=0;i<n;i++){
		pq.push({-1*(a[i]/b[i]+1),{i,0}});
	}
	for(ll i=1;i<=k;i++){
		pair<ll,pll > f=pq.top();
		pq.pop();
		if(-f.fi-i<0){
			return 0;
		}
		pq.push({-1*((a[f.se.fi]+f.se.se*x+x)/b[f.se.fi]+1),{f.se.fi,f.se.se+1}});
	}
	return 1;
}

int main(){FAST;
cin>>n>>k;
for(ll i=0;i<n;i++){
	cin>>a[i];
}
for(ll i=0;i<n;i++){
	cin>>b[i];
}
ll lo=0,hi=1e18;
while(lo<hi){
	ll mid=(lo+hi)>>1LL;
	cout<<mid<<'\n';
	if(check(mid)){
		hi=mid;
	}
	else{
		lo=mid+1;
	}
}
if(lo==1e18){
	cout<<-1;
}
else{
	cout<<lo;
}
return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/

ll n,k;
ll a[200005],b[200005];
/*
ll check(ll x){
	priority_queue<pair<ll,pll > >pq;
//	cout<<" MID "<<x<<'\n';
	for(ll i=0;i<n;i++){
		pq.push({-1*(a[i]/b[i]+1),{i,0}});
	}
	for(ll i=1;i<=k;i++){
		if(pq.empty())break;
		pair<ll,pll > f=pq.top();
		pq.pop();
//		cout<<f.se.fi<<'\n';
		if(-f.fi-i<0){
			return 0;
		}
		ll sec = (a[f.se.fi]+f.se.se*x+x)/b[f.se.fi]+1;
//		cout<<sec<<'\n';
		if(sec < k){
			pq.push({-1*((a[f.se.fi]+f.se.se*x+x)/b[f.se.fi]+1),{f.se.fi,f.se.se+1}});
		}
	}
//	cout<<'\n';
	return 1;
}*/
vll g[200005];

ll check(ll x){
	for(ll i=0;i<200004;i++){
		g[i].clear();
	}
	for(ll i=0;i<n;i++){
		ll sec = a[i]/b[i]+1;
		if(sec < k)
		g[sec].pb({i,0});
	}
	ll j=1;
	for(ll i=1;i<k;i++){
		while(j<k and g[j].empty())j++;
		if(j==k)break;
		if(i == j and g[i].size() > 1)return 0;
		ll idx=g[j].back().first;
		ll y=g[j].back().second;
		g[j].pop_back();
		ll sec = (a[idx]+y*x+x)/b[idx]+1;
		if(sec < k and sec > i){
			g[sec].pb({idx,y+1});
		}
		else if(sec <= i){
			return 0;
		}
	}
	return 1;
}

int main(){FAST;
cin>>n>>k;
for(ll i=0;i<n;i++){
	cin>>a[i];
}
for(ll i=0;i<n;i++){
	cin>>b[i];
}
ll lo=0,hi=1e18;
while(lo<hi){
	ll mid=(lo+hi)>>1LL;
//	cout<<mid<<'\n';
	if(check(mid)){
		hi=mid;
	}
	else{
		lo=mid+1;
	}
}
if(lo==1e18){
	cout<<-1;
}
else{
	cout<<lo;
}
return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/

ll n,k;
ll a[200005],b[200005];
ll check(ll x){
	priority_queue<pair<ll,pll > >pq;
//	cout<<" MID "<<x<<'\n';
	for(ll i=0;i<n;i++){
		pq.push({-1*(a[i]/b[i]+1),{i,0}});
	}
	for(ll i=1;i<=k;i++){
		if(pq.empty())break;
		pair<ll,pll > f=pq.top();
		pq.pop();
//		cout<<f.se.fi<<'\n';
		if(-f.fi-i<0){
			return 0;
		}
		ll sec = (a[f.se.fi]+f.se.se*x+x)/b[f.se.fi]+1;
//		cout<<sec<<'\n';
		if(sec < k){
			pq.push({-1*((a[f.se.fi]+f.se.se*x+x)/b[f.se.fi]+1),{f.se.fi,f.se.se+1}});
		}
	}
//	cout<<'\n';
	return 1;
}

int main(){FAST;
cin>>n>>k;
for(ll i=0;i<n;i++){
	cin>>a[i];
}
for(ll i=0;i<n;i++){
	cin>>b[i];
}
ll lo=0,hi=1e18;
while(lo<hi){
	ll mid=(lo+hi)>>1LL;
//	cout<<mid<<'\n';
	if(check(mid)){
		hi=mid;
	}
	else{
		lo=mid+1;
	}
}
if(lo==1e18){
	cout<<-1;
}
else{
	cout<<lo;
}
return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/

ll n,k;
ll a[200005],b[200005];

ll check(ll x){
	priority_queue<pair<ll,pll > >pq;
	for(ll i=0;i<n;i++){
		ll sec = a[i]/b[i]+1;
		if(sec < k);
		pq.push({-sec,{i,0}});
	}
	for(ll i=1;i<=k;i++){
		if(pq.empty())break;
		pair<ll,pll > f=pq.top();
		pq.pop();
		if(-f.fi-i<0){
			return 0;
		}
		ll sec = (a[f.se.fi]+f.se.se*x+x)/b[f.se.fi]+1;
		if(sec < k){
			pq.push({-sec,{f.se.fi,f.se.se+1}});
		}
	}
	return 1;
}
/*
vll g[200005];
ll check(ll x){
	for(ll i=0;i<200004;i++){
		g[i].clear();
	}
	for(ll i=0;i<n;i++){
		ll sec = a[i]/b[i]+1;
		if(sec < k)
		g[sec].pb({i,0});
	}
	ll j=1;
	for(ll i=1;i<k;i++){
		while(j<k and g[j].empty())j++;
		if(j==k)break;
		if(i == j and g[i].size() > 1)return 0;
		ll idx=g[j].back().first;
		ll y=g[j].back().second;
		g[j].pop_back();
		ll sec = (a[idx]+y*x+x)/b[idx]+1;
		if(sec < k and sec > i){
			g[sec].pb({idx,y+1});
		}
		else if(sec <= i){
			return 0;
		}
	}
	return 1;
}
*/
int main(){FAST;
cin>>n>>k;
for(ll i=0;i<n;i++){
	cin>>a[i];
}
for(ll i=0;i<n;i++){
	cin>>b[i];
}
ll lo=0,hi=2e12+5;
while(lo<hi){
	ll mid=(lo+hi)>>1LL;
	if(check(mid)){
		hi=mid;
	}
	else{
		lo=mid+1;
	}
}
if(lo==2e12+5){
	cout<<-1;
}
else{
	cout<<lo;
}
return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/

ll n,k;
ll a[200005],b[200005];
/*
ll check(ll x){
	priority_queue<pair<ll,pll > >pq;
//	cout<<" MID "<<x<<'\n';
	for(ll i=0;i<n;i++){
		pq.push({-1*(a[i]/b[i]+1),{i,0}});
	}
	for(ll i=1;i<=k;i++){
		if(pq.empty())break;
		pair<ll,pll > f=pq.top();
		pq.pop();
//		cout<<f.se.fi<<'\n';
		if(-f.fi-i<0){
			return 0;
		}
		ll sec = (a[f.se.fi]+f.se.se*x+x)/b[f.se.fi]+1;
//		cout<<sec<<'\n';
		if(sec < k){
			pq.push({-1*((a[f.se.fi]+f.se.se*x+x)/b[f.se.fi]+1),{f.se.fi,f.se.se+1}});
		}
	}
//	cout<<'\n';
	return 1;
}*/
vll g[200005];

ll check(ll x){
	for(ll i=0;i<200005;i++){
		g[i].clear();
	}
	for(ll i=0;i<n;i++){
		g[a[i]/b[i]+1].pb({i,0});
	}
	ll j=1;
	for(ll i=1;i<=k;i++){
		while(j<k and g[j].empty())j++;
		if(j==k)break;
		if(i == j and g[i].size() > 1)return 0;
		ll idx=g[j].back().first;
		ll y=g[j].back().second;
		g[j].pop_back();
		ll sec = (a[idx]+y*x+x)/b[idx]+1;
		if(sec < k and sec > i){
			g[(a[idx]+y*x+x)/b[idx]+1].pb({idx,y+1});
		}
		else if(sec <= i){
			return 0;
		}
	}
	return 1;
}

int main(){FAST;
cin>>n>>k;
for(ll i=0;i<n;i++){
	cin>>a[i];
}
for(ll i=0;i<n;i++){
	cin>>b[i];
}
ll lo=0,hi=1e18;
while(lo<hi){
	ll mid=(lo+hi)>>1LL;
//	cout<<mid<<'\n';
	if(check(mid)){
		hi=mid;
	}
	else{
		lo=mid+1;
	}
}
if(lo==1e18){
	cout<<-1;
}
else{
	cout<<lo;
}
return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/

ll n,k;
ll a[200005],b[200005];
ll check(ll x){
	priority_queue<pair<ll,pll > >pq;
	for(ll i=0;i<n;i++){
		pq.push({-1*(a[i]/b[i]+1),{i,0}});
	}
	for(ll i=1;i<=k;i++){
		pair<ll,pll > f=pq.top();
		pq.pop();
		if(-f.fi-i<0){
			return 0;
		}
		pq.push({-1*((a[f.se.fi]+f.se.se*x+x)/b[f.se.fi]+1),{f.se.fi,f.se.se+1}});
	}
	return 1;
}

int main(){FAST;
cin>>n>>k;
for(ll i=0;i<n;i++){
	cin>>a[i];
}
for(ll i=0;i<n;i++){
	cin>>b[i];
}
ll lo=0,hi=1e18;
while(lo<hi){
	ll mid=(lo+hi)>>1LL;
//	cout<<mid<<'\n';
	if(check(mid)){
		hi=mid;
	}
	else{
		lo=mid+1;
	}
}
if(lo==1e18){
	cout<<-1;
}
else{
	cout<<lo;
}
return 0;
}


#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount _builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace __gnu_pbds;
using namespace std;
//typedef
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
//constants
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
// gcd of a and b
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
// distance between (a,b) and (c,d)
long double dis(long long a,long long b,long long c,long long d){return sqrt( ((a)-(c))*((a)-(c))+((b)-(d))*((b)-(d)) );}
// simple prime check
bool isprime(long long a){
if(a==2)return 1;
if(!(a&1))return 0;
for(ll i=3;i*i<=a;i+=2){
	if(a%i==0)return 0;
}
return 1;
}
// fast expo
long long mpow(long long base,long long exponent,long long modulus){
if(modulus==1)return 0;
long long result = 1;
base=base%modulus;
while(exponent){
		if(exponent%2 == 1)
			result=(result*base)%modulus;
		exponent=exponent>>1;
		base=(base*base)%modulus;
	}
return result;
}
// modular inverse
ll minv(ll a,ll mod){
	ll _gcd=gcd(a,mod);
	assert(_gcd==1);
	return mpow(a,mod-2,mod);
}

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/

/*
ll dx[]={1,0,-1,0,1,1,-1,-1};
ll dy[]={0,-1,0,1,1,-1,-1,1};
*/

/*
void sieve(int N){
	for(int i=0;i<=N;i++){
		spf[i]=i;
	}
	for(int i=2;i*i<=N;i++){
		if(spf[i]==i){
			for(int j=i*i;j<=N;j+=i){
				spf[j]=min(spf[j],i);
			}
		}
	}
	return;
}
*/

/*
void nCr(ll n,ll k){
	ll i,j;
	for(i=0;i<=n;i++){
		for(j=0;j<=min(i,k);j++){

			if(j==0 or j==i)C[i][j]=1LL;
			else  C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;

		}
	}
	return;
}
*/
/*
ll ncr(ll N,ll K){
	if(N<K)return 0;
	if(K==0)return 1;
	if(N==0)return 0;

	ll den=1;
	for(ll i=1;i<=K;i++)den*=i;
	ll num=1;
	while(K--){
		num*=N;
		if(num%den==0){
			num/=den;
			den=1;
		}
		N--;
	}

	return num;
}
*/

ll n,k;
ll a[200005],b[200005];
/*
ll check(ll x){
	priority_queue<pair<ll,pll > >pq;
//	cout<<" MID "<<x<<'\n';
	for(ll i=0;i<n;i++){
		pq.push({-1*(a[i]/b[i]+1),{i,0}});
	}
	for(ll i=1;i<=k;i++){
		if(pq.empty())break;
		pair<ll,pll > f=pq.top();
		pq.pop();
//		cout<<f.se.fi<<'\n';
		if(-f.fi-i<0){
			return 0;
		}
		ll sec = (a[f.se.fi]+f.se.se*x+x)/b[f.se.fi]+1;
//		cout<<sec<<'\n';
		if(sec < k){
			pq.push({-1*((a[f.se.fi]+f.se.se*x+x)/b[f.se.fi]+1),{f.se.fi,f.se.se+1}});
		}
	}
//	cout<<'\n';
	return 1;
}*/
vll g[200005];

ll check(ll x){
	for(ll i=0;i<200005;i++){
		g[i].clear();
	}
	for(ll i=0;i<n;i++){
		g[a[i]/b[i]+1].pb({i,0});
	}
	ll j=1;
	for(ll i=1;i<k;i++){
		while(j<k and g[j].empty())j++;
		if(j==k)break;
		if(i == j and g[i].size() > 1)return 0;
		ll idx=g[j].back().first;
		ll y=g[j].back().second;
		g[j].pop_back();
		ll sec = (a[idx]+y*x+x)/b[idx]+1;
		if(sec < k and sec > i){
			g[sec].pb({idx,y+1});
		}
		else if(sec <= i){
			return 0;
		}
	}
	return 1;
}

int main(){FAST;
cin>>n>>k;
for(ll i=0;i<n;i++){
	cin>>a[i];
}
for(ll i=0;i<n;i++){
	cin>>b[i];
}
ll lo=0,hi=1e18;
while(lo<hi){
	ll mid=(lo+hi)>>1LL;
//	cout<<mid<<'\n';
	if(check(mid)){
		hi=mid;
	}
	else{
		lo=mid+1;
	}
}
if(lo==1e18){
	cout<<-1;
}
else{
	cout<<lo;
}
return 0;
}


//
#include <bits/stdc++.h>

#define endl '\n'
#define int ll
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define power first
#define usage second

struct Cmp
{
    bool operator () (const P &lhs, const P &rhs)
    {
        return lhs.power/lhs.usage > rhs.power/rhs.usage;
    }
};

typedef priority_queue<P, vector<P>, Cmp> PQ;

const int N = 200005;

ll n, totTime;
PQ init_pq;

void init();
void process();

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n >> totTime;
    ll initPw[N], usage[N];
    for(int i = 0; i < n; i++) cin >> initPw[i];
    for(int i = 0; i < n; i++) cin >> usage[i];
    for(int i = 0; i < n; i++)
    {
        init_pq.emplace(initPw[i], usage[i]);
    }
}

bool ok(ll charge)
{
    PQ pq = init_pq;
    for(ll t = 1; t < totTime; t++)
    {
        P f = pq.top(); pq.pop();
        f.power += charge;
        pq.push(f);
        f = pq.top();
        if(f.usage*t > f.power) return false;
    }
    return true;
}

void process()
{
    ll low = 0, high = 1e11, mid, ans = -1;
    while(low <= high)
    {
        mid = (low+high)/2;
        if(ok(mid)) ans = mid, high = mid-1;
        else low = mid+1;
    }
    cout << ans << endl;
}


//
#include <bits/stdc++.h>

#define endl '\n'
#define int ll
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define power first
#define usage second

struct Cmp
{
    bool operator () (const P &lhs, const P &rhs)
    {
        return lhs.power/lhs.usage > rhs.power/rhs.usage;
    }
};

typedef priority_queue<P, vector<P>, Cmp> PQ;

const int N = 200005;

ll n, totTime;
PQ init_pq;

void init();
void process();

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n >> totTime;
    ll initPw[N], usage[N];
    for(int i = 0; i < n; i++) cin >> initPw[i];
    for(int i = 0; i < n; i++) cin >> usage[i];
    for(int i = 0; i < n; i++)
    {
        init_pq.emplace(initPw[i], usage[i]);
    }
}

bool ok(ll charge)
{
    PQ pq = init_pq;
    for(ll t = 1; t < totTime; t++)
    {
        P f = pq.top(); pq.pop();
        f.power += charge;
        pq.push(f);
        f = pq.top();
        if(f.usage*t > f.power) return false;
    }
    return true;
}

void bs(ll l, ll h)
{
    ll low = l, high = h, mid, ans = -1;
    while(low <= high)
    {
        mid = (low+high)/2;
        if(ok(mid)) ans = mid, high = mid-1;
        else low = mid+1;
    }
    cout << ans << endl;
}

void process()
{
    // exp
    ll pw = 1;
    while(!ok(pw)) pw *= 2;
    bs(pw/2, pw);
}


//
#include <bits/stdc++.h>

#define endl '\n'
#define int ll
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define power first
#define usage second

struct Cmp
{
    bool operator () (const P &lhs, const P &rhs)
    {
        return lhs.power/lhs.usage > rhs.power/rhs.usage;
    }
};

typedef priority_queue<P, vector<P>, Cmp> PQ;

const int N = 200005;

ll n, totTime;
PQ init_pq;

void init();
void process();

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n >> totTime;
    ll initPw[N], usage[N];
    for(int i = 0; i < n; i++) cin >> initPw[i];
    for(int i = 0; i < n; i++) cin >> usage[i];
    for(int i = 0; i < n; i++)
    {
        init_pq.emplace(initPw[i], usage[i]);
    }
}

bool ok(ll charge)
{
    PQ pq = init_pq;
    for(ll t = 1; t < totTime; t++)
    {
        P f = pq.top(); pq.pop();
        f.power += charge;
        pq.push(f);
        f = pq.top();
        if(f.usage*t > f.power) return false;
    }
    return true;
}

void bs(ll l, ll h)
{
    ll low = l, high = h, mid, ans = -1;
    while(low <= high)
    {
        mid = (low+high)/2;
        if(ok(mid)) ans = mid, high = mid-1;
        else low = mid+1;
    }
    cout << ans << endl;
}

void process()
{
    // exp
    ll MAX = 2000000000000ll;
    ll pw = 1;
    while(!ok(pw) && pw < MAX) pw *= 2;
    if(pw >= MAX) cout << -1 << endl;
    else bs(pw/2, pw);
}


//
#include <bits/stdc++.h>

#define endl '\n'
#define int ll
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define power first
#define usage second

struct Cmp
{
    bool operator () (const P &lhs, const P &rhs)
    {
        return lhs.power/lhs.usage > rhs.power/rhs.usage;
    }
};

typedef priority_queue<P, vector<P>, Cmp> PQ;

const int N = 200005;

ll n, totTime;
PQ init_pq;

void init();
void process();

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n >> totTime;
    ll initPw[N], usage[N];
    for(int i = 0; i < n; i++) cin >> initPw[i];
    for(int i = 0; i < n; i++) cin >> usage[i];
    for(int i = 0; i < n; i++)
    {
        init_pq.emplace(initPw[i], usage[i]);
    }
}

bool ok(ll charge)
{
    PQ pq = init_pq;
    for(ll t = 1; t < totTime; t++)
    {
        P f = pq.top(); pq.pop();
        f.power += charge;
        pq.push(f);
        f = pq.top();
        if(f.usage*t > f.power) return false;
    }
    return true;
}

void process()
{
    ll low = 0, high = 5000000000, mid, ans = -1;
    while(low <= high)
    {
        mid = (low+high)/2;
        if(ok(mid)) ans = mid, high = mid-1;
        else low = mid+1;
    }
    cout << ans << endl;
}


//
#include <bits/stdc++.h>

#define endl '\n'
#define int ll
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define power first
#define usage second

struct Cmp
{
    bool operator () (const P &lhs, const P &rhs)
    {
        return lhs.power/lhs.usage > rhs.power/rhs.usage;
    }
};

typedef priority_queue<P, vector<P>, Cmp> PQ;

const int N = 200005;

ll n, totTime;
PQ init_pq;

void init();
void process();

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n >> totTime;
    ll initPw[N], usage[N];
    for(int i = 0; i < n; i++) cin >> initPw[i];
    for(int i = 0; i < n; i++) cin >> usage[i];
    for(int i = 0; i < n; i++)
    {
        init_pq.emplace(initPw[i], usage[i]);
    }
}

bool ok(ll charge)
{
    PQ pq = init_pq;
    for(ll t = 1; t < totTime; t++)
    {
        P f = pq.top(); pq.pop();
        f.power += charge;
        pq.push(f);
        f = pq.top();
        if(f.usage*t > f.power) return false;
    }
    return true;
}

void process()
{
    ll low = 0, high = 1000000000000ll, mid, ans = -1;
    while(low <= high)
    {
        mid = (low+high)/2;
        if(ok(mid)) ans = mid, high = mid-1;
        else low = mid+1;
    }
    cout << ans << endl;
}


//
#include <bits/stdc++.h>

#define endl '\n'
#define int ll
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define power first
#define usage second

struct Cmp
{
    bool operator () (const P &lhs, const P &rhs)
    {
        return lhs.power/lhs.usage > rhs.power/rhs.usage;
    }
};

typedef priority_queue<P, vector<P>, Cmp> PQ;

const int N = 200005;

ll n, totTime;
PQ init_pq;

void init();
void process();

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n >> totTime;
    ll initPw[N], usage[N];
    for(int i = 0; i < n; i++) cin >> initPw[i];
    for(int i = 0; i < n; i++) cin >> usage[i];
    for(int i = 0; i < n; i++)
    {
        init_pq.emplace(initPw[i], usage[i]);
    }
}

bool ok(ll charge)
{
    PQ pq = init_pq;
    for(ll t = 1; t < totTime; t++)
    {
        P f = pq.top(); pq.pop();
        f.power += charge;
        pq.push(f);
        f = pq.top();
        if(f.usage*t > f.power) return false;
    }
    return true;
}

void bs(ll l, ll h)
{
    ll low = l, high = h, mid, ans = -1;
    while(low <= high)
    {
        mid = (low+high)/2;
        if(ok(mid)) ans = mid, high = mid-1;
        else low = mid+1;
    }
    cout << ans << endl;
}

void process()
{
    // exp
    ll MAX = 4000000000000ll;
    ll pw = 1;
    while(!ok(pw) && pw < MAX) pw *= 2;
    if(pw >= MAX) cout << -1 << endl;
    else bs(pw/2, pw);
}


//
#include <bits/stdc++.h>

#define endl '\n'
#define int ll
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define power first
#define usage second

struct Cmp
{
    bool operator () (const P &lhs, const P &rhs)
    {
        return lhs.power/lhs.usage > rhs.power/rhs.usage;
    }
};

typedef priority_queue<P, vector<P>, Cmp> PQ;

const int N = 200005;

ll n, totTime;
PQ init_pq;

void init();
void process();

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n >> totTime;
    ll initPw[N], usage[N];
    for(int i = 0; i < n; i++) cin >> initPw[i];
    for(int i = 0; i < n; i++) cin >> usage[i];
    for(int i = 0; i < n; i++)
    {
        init_pq.emplace(initPw[i], usage[i]);
    }
}

bool ok(ll charge)
{
    PQ pq = init_pq;
    for(ll t = 1; t < totTime; t++)
    {
        P f = pq.top(); pq.pop();
        f.power += charge;
        pq.push(f);
        f = pq.top();
        if(f.usage*t > f.power) return false;
    }
    return true;
}

void process()
{
    ll low = 0, high = 1000000000, mid, ans = -1;
    while(low <= high)
    {
        mid = (low+high)/2;
        if(ok(mid)) ans = mid, high = mid-1;
        else low = mid+1;
    }
    cout << ans << endl;
}


//
#include <bits/stdc++.h>

#define endl '\n'
#define int ll
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define power first
#define usage second

struct Cmp
{
    bool operator () (const P &lhs, const P &rhs)
    {
        return lhs.power/lhs.usage > rhs.power/rhs.usage;
    }
};

typedef priority_queue<P, vector<P>, Cmp> PQ;

const int N = 200005;

ll n, totTime;
PQ init_pq;

void init();
void process();

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n >> totTime;
    ll initPw[N], usage[N];
    for(int i = 0; i < n; i++) cin >> initPw[i];
    for(int i = 0; i < n; i++) cin >> usage[i];
    for(int i = 0; i < n; i++)
    {
        init_pq.emplace(initPw[i], usage[i]);
    }
}

bool ok(ll charge)
{
    PQ pq = init_pq;
    for(ll t = 1; t < totTime; t++)
    {
        P f = pq.top(); pq.pop();
        f.power += charge;
        pq.push(f);
        f = pq.top();
        if(f.usage*t > f.power) return false;
    }
    return true;
}

void process()
{
    ll low = 0, high = 10000000000, mid, ans = -1;
    while(low <= high)
    {
        mid = (low+high)/2;
        if(ok(mid)) ans = mid, high = mid-1;
        else low = mid+1;
    }
    cout << ans << endl;
}


//
#include <bits/stdc++.h>

#define endl '\n'
#define int ll
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define power first
#define usage second

struct Cmp
{
    bool operator () (const P &lhs, const P &rhs)
    {
        return lhs.power/lhs.usage > rhs.power/rhs.usage;
    }
};

typedef priority_queue<P, vector<P>, Cmp> PQ;

const int N = 200005;

ll n, totTime;
PQ init_pq;

void init();
void process();

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    init();
    process();
    cout.flush();
    return 0;
}

void init()
{
    cin >> n >> totTime;
    ll initPw[N], usage[N];
    for(int i = 0; i < n; i++) cin >> initPw[i];
    for(int i = 0; i < n; i++) cin >> usage[i];
    for(int i = 0; i < n; i++)
    {
        init_pq.emplace(initPw[i], usage[i]);
    }
}

bool ok(ll charge)
{
    PQ pq = init_pq;
    for(ll t = 1; t < totTime; t++)
    {
        P f = pq.top(); pq.pop();
        f.power += charge;
        pq.push(f);
        f = pq.top();
        if(f.usage*t > f.power) return false;
    }
    return true;
}

void bs(ll l, ll h)
{
    ll low = l, high = h, mid, ans = -1;
    while(low <= high)
    {
        mid = (low+high)/2;
        if(ok(mid)) ans = mid, high = mid-1;
        else low = mid+1;
    }
    cout << ans << endl;
}

void process()
{
    // exp
    ll MAX = 1000000000000ll;
    ll pw = 1;
    while(!ok(pw) && pw < MAX) pw *= 2;
    if(pw >= MAX) cout << -1 << endl;
    else bs(pw/2, pw);
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++) heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    LL li=0,ri=0;
    for(int i=1;i<=n;i++)  li+=max(0LL,(m-1)*b[i]-a[i]);
    li/=m;
    li--;
    for(int i=1;i<=n;i++) ri=max(ri,(m-1)*b[i]-a[i]);
    ri++;
    cout<<sol(li,ri)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++) heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    cout<<sol(0LL,10000000000000LL)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left && a.cost*b.left==a.left*b.cost) return a.cost<b.cost;
    if(a.left==b.left) return a.left*1.0/a.cost>b.left*1.0/b.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++) heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    cout<<sol(0,1e13)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++) heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    LL li=0,ri=0;
    for(int i=1;i<=n;i++)  li+=max(0LL,(m-1)*b[i]-a[i]);
    li/=m;
    li--;
    li=max(li,0LL);
    for(int i=1;i<=n;i++) ri=max(ri,m*b[i]);
    ri++;
    ri=max(ri,0LL);
    cout<<sol(li,ri)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++) heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    LL li=0,ri=0;
    for(int i=1;i<=n;i++)  li+=max(0LL,(m-1)*b[i]-a[i]);
    li/=m;
    li--;
    li=max(li,0);
//    li=max(li,1LL);
//    for(int i=1;i<=n;i++) ri=max(ri,(m-1)*b[i]-a[i]);
//    ri++;
//    ri=max(ri,1LL);
    cout<<sol(li,1e13)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++) heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    LL li=0,ri=0;
    for(int i=1;i<=n;i++)  li+=max(0LL,(m-1)*b[i]-a[i]);
    li/=m;
    li--;
    li=max(li,1LL);
    cout<<sol(li,1e13)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++)
    {
        heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
        if(b[i]*(m-1)>a[i]+cha*(m-1)) return false;
    }
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
//    LL li=0,ri=0;
//    for(int i=1;i<=n;i++)  li+=max(0LL,(m-1)*b[i]-a[i]);
//    li/=m;
//    li--;
//    li=max(li,0LL);
//    for(int i=1;i<=n;i++) ri=max(ri,m*b[i]);
//    ri++;
//    ri=max(ri,0LL);
    cout<<sol(0,1e13)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++)  heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    if(deal(lt)) return lt;
    if(!deal(rt)) return -1;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
//    LL li=0,ri=0;
//    for(int i=1;i<=n;i++)  li+=max(0LL,(m-1)*b[i]-a[i]),ri=max(ri,m*b[i]);
//    li/=m;
//    li--;
//    li=max(li,0LL);
//    ri++;
//    ri=max(ri,0LL);
    cout<<sol(0LL,1e13)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++)  heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    if(deal(lt)) return lt;
    if(!deal(rt)) return -1;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
//    LL li=0,ri=0;
//    for(int i=1;i<=n;i++)  li+=max(0LL,(m-1)*b[i]-a[i]),ri=max(ri,m*b[i]);
//    li/=m;
//    li--;
//    li=max(li,0LL);
//    ri++;
//    ri=max(ri,0LL);
    cout<<sol(0,1e13)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++)
    {
        heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
        if(b[i]*(m-1)>a[i]+cha*(m-1)) return false;
    }
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    LL li=0,ri=0;
    for(int i=1;i<=n;i++)  li+=max(0LL,(m-1)*b[i]-a[i]),ri=max(ri,m*b[i]);
    li/=m;
    li--;
    li=max(li,0LL);
    ri++;
    ri=max(ri,0LL);
    cout<<sol(li,ri)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++) heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    LL li=0,ri=0;
    for(int i=1;i<=n;i++)  li+=max(0LL,(m-1)*b[i]-a[i]);
    li/=m;
    li--;
    li=max(li,1LL);
    for(int i=1;i<=n;i++) ri=max(ri,(m-1)*b[i]-a[i]);
    ri++;
    ri=max(ri,1LL);
    cout<<sol(li,ri)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
const double eps=1e-6;
int n,m;
struct obj{
    double left;
    LL cost;
};
bool operator < (const obj &a,const obj &b)
{
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++) heap.push((obj){a[i]*1.0/b[i],b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1-eps) return false;
        x.left+=cha*1.0/x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    cout<<sol(0,1e13)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++) heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    li=max(li,0LL);
    cout<<sol(0LL,100000000000000LL)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++) heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
//    LL li=0,ri=0;
//    for(int i=1;i<=n;i++)  li+=max(0LL,(m-1)*b[i]-a[i]);
//    li/=m;
//    li--;
//    li=max(li,1LL);
//    for(int i=1;i<=n;i++) ri=max(ri,(m-1)*b[i]-a[i]);
//    ri++;
//    ri=max(ri,1LL);
    cout<<sol(0,1e13)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++) heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    LL li=0,ri=0;
    for(int i=1;i<=n;i++)  li+=max(0LL,(m-1)*b[i]-a[i]);
    li/=m;
    li--;
    li=max(li,0LL);
    cout<<sol(li,1e15)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++) heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    LL li=0,ri=0;
    for(int i=1;i<=n;i++)  li+=max(0LL,(m-1)*b[i]-a[i]);
    li/=m;
    li--;
    li=max(li,0LL);
//    li=max(li,1LL);
//    for(int i=1;i<=n;i++) ri=max(ri,(m-1)*b[i]-a[i]);
//    ri++;
//    ri=max(ri,1LL);
    cout<<sol(li,1e13)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++) heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
//    ios::sync_with_stdio(false);
//    cin.tie(0);
//    cout.tie(0);
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%I64d",a+i);
    for(int i=1;i<=n;i++) scanf("%I64d",b+i);
    printf("%I64d",sol(0,1e13));
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++) heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
//    ios::sync_with_stdio(false);
//    cin.tie(0);
//    cout.tie(0);
    scanf("%I64d%I64d",&n,&m);
    for(int i=1;i<=n;i++) scanf("%I64d",a+i);
    for(int i=1;i<=n;i++) scanf("%I64d",b+i);
    printf("%I64d",sol(0,1e13));
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++) heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    LL li=0,ri=0;
    for(int i=1;i<=n;i++)  li+=max(0LL,(m-1)*b[i]-a[i]);
    li/=m;
    li--;
    li=max(li,1);
    for(int i=1;i<=n;i++) ri=max(ri,(m-1)*b[i]-a[i]);
    ri++;
    ri=max(ri,1);
    cout<<sol(li,ri)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++)
    {
        heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
        if(b[i]*(m-1)>a[i]+cha*m) return false;
    }
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
//    LL li=0,ri=0;
//    for(int i=1;i<=n;i++)  li+=max(0LL,(m-1)*b[i]-a[i]);
//    li/=m;
//    li--;
//    li=max(li,0LL);
//    for(int i=1;i<=n;i++) ri=max(ri,m*b[i]);
//    ri++;
//    ri=max(ri,0LL);
    cout<<sol(0,1e13)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++) heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    LL li=0,ri=0;
    for(int i=1;i<=n;i++)  li+=max(0LL,m*b[i]-a[i]);
    li/=m;
    li--;
    for(int i=1;i<=n;i++) ri=max(ri,m*b[i]-a[i]);
    ri++;
    cout<<sol(li,ri)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++) heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    LL li=0,ri=0;
    for(int i=1;i<=n;i++)  li+=max(0LL,(m-1)*b[i]-a[i]);
    li/=m;
    li--;
    li=max(li,0LL);
    cout<<sol(0LL,1000000000000000LL)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++) heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    cout<<sol(0,1e13)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left && a.cost*b.left==a.left*b.cost) return a.cost<b.cost;
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++) heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    cout<<sol(0,1e13)<<endl;
    return 0;
}


#include<bits/stdc++.h>
#define clr(x) memset(x,0,sizeof(x))
#define INF 0x3f3f3f3f
#define mod 1000000007
#define LL long long
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
int n,m;
struct obj{
    LL cost,more,left;
};
bool operator < (const obj &a,const obj &b)
{
    if(a.left==b.left) return a.left*b.cost>b.left*a.cost;
    return a.left>b.left;
}
LL a[N],b[N];
bool deal(LL cha)
{
    priority_queue<obj> heap;
    for(int i=1;i<=n;i++) heap.push((obj){b[i],a[i]%b[i],a[i]/b[i]});
    obj x;
    LL ct;
    for(int i=1;i<=m;i++)
    {
        x=heap.top();
        heap.pop();
        if(x.left<i-1) return false;
        ct=x.more+cha;
        x.left+=ct/x.cost;
        x.more=ct%x.cost;
        heap.push(x);
    }
    return true;
}
LL sol(LL lt,LL rt)
{
    LL mid;
    LL ans=rt;
    while(lt<=rt)
    {
        mid=(lt+rt)/2;
        if(deal(mid)) ans=mid,rt=mid-1;
        else lt=mid+1;
    }
    if(ans==rt) return -1;
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) cin>>b[i];
    cout<<sol(0,1e10)<<endl;
    return 0;
}


#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
struct student
{
	long long charge;
	long long usage;
	long long time;
	bool operator <(const student& r)const { return time > r.time; }
}s[200005];
int n, k;
bool judge(long long power)
{
	priority_queue<student> q;
	while (!q.empty()) q.pop();
	for (int i = 1; i <= n; i++)
	{
		q.push(student{ s[i].charge,s[i].usage ,s[i].charge / s[i].usage });
	}
	student temp;
	for (int i = 1; i <= k; i++)
	{
		temp = q.top();
		q.pop();
		if (temp.charge / temp.usage < i - 1) return false;
		temp.charge += power;
		temp.time = temp.charge / temp.usage;
		q.push(temp);
	}
	return true;
}
int main()
{
	while (scanf("%d%d",&n,&k)!=EOF)
	{
		for (int i = 1; i <= n; i++)scanf("%I64d", &s[i].charge);
		for (int i = 1; i <= n; i++) scanf("%I64d", &s[i].usage);
		if (judge(1e13) == false)
		{
			cout << -1 << endl;
			continue;
		}
		else
		{
			long long l = 0, r = 1e13;
			while (l < r)
			{
				long long mid = (l + r) >> 1;
				if (!judge(mid))
				{
					l = mid + 1;
				}
				else
				{
					r = mid;
				}
			}
			cout << r << endl;
		}
	}
}


#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
using namespace std;
int dp[505][505];
int main()
{
	int n;
	string ss;
	while (cin >> n >> ss)
	{
		ss = "A" + ss;
		for (int i = 1; i <= n; i++) dp[i][i] = 1;
		for (int gap = 1; gap < n; gap++)
		{
			for (int left = 1; left + gap <= n; left++)
			{
				int right = left + gap;
				dp[left][right] = min(dp[left + 1][right], dp[left][right - 1]) + 1;
				if (ss[left] == ss[left+1])
				{
					dp[left][right] = min(dp[left][right], dp[left + 1][right]);
				}
				if (ss[right] == ss[right - 1])
				{
					dp[left][right] = min(dp[left][right], dp[left][right - 1]);
				}
				if (ss[left] == ss[right]) dp[left][right] = min(dp[left + 1][right], dp[left][right - 1]);
			}
		}
		cout << dp[1][n] << endl;
	}
}


#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
struct student
{
	long long charge;
	long long usage;
	bool operator <(const student& r)const { return charge / usage > r.charge / r.usage; }
}s[200005];
int n, k;
bool judge(long long power)
{
	priority_queue<student> q;
	while (!q.empty()) q.pop();
	for (int i = 1; i <= n; i++)
	{
		q.push(student{ s[i].charge,s[i].usage });
	}
	student temp;
	for (int i = 1; i <= k; i++)
	{
		temp = q.top();
		q.pop();
		if (temp.charge / temp.usage < i - 1) return false;
		temp.charge += power;
		q.push(temp);
	}
	return true;
}
int main()
{
	ios::sync_with_stdio("false");
	while (cin >> n >> k)
	{
		for (int i = 1; i <= n; i++)cin >> s[i].charge;
		for (int i = 1; i <= n; i++) cin >> s[i].usage;
		if (judge(1e13) == false)
		{
			cout << -1 << endl;
			continue;
		}
		else
		{
			long long l = 0, r = 1e13;
			while (l < r)
			{
				long long mid = (l + r) >> 1;
				if (!judge(mid))
				{
					l = mid + 1;
				}
				else
				{
					r = mid;
				}
			}
			cout << r << endl;
		}
	}
}


#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
struct student
{
	long long charge;
	long long usage;
	bool operator <(const student& r)const { return charge / usage > r.charge / r.usage; }
}s[200005];
int n, k;
bool judge(long long power)
{
	priority_queue<student> q;
	while (!q.empty()) q.pop();
	for (int i = 1; i <= n; i++)
	{
		q.push(student{ s[i].charge,s[i].usage });
	}
	student temp;
	for (int i = 1; i <= k; i++)
	{
		temp = q.top();
		q.pop();
		if (temp.charge / temp.usage < i - 1) return false;
		temp.charge += power;
		q.push(temp);
	}
	if (q.top().charge / q.top().usage < k) return false;
	return true;
}
int main()
{
	while (scanf("%d%d",&n,&k)!=EOF)
	{
		for (int i = 1; i <= n; i++)scanf("%I64d", &s[i].charge);
		for (int i = 1; i <= n; i++) scanf("%I64d", &s[i].usage);
		if (judge(1e13) == false)
		{
			cout << -1 << endl;
			continue;
		}
		else
		{
			long long l = 0, r = 1e13;
			while (l < r)
			{
				long long mid = (l + r) >> 1;
				if (!judge(mid))
				{
					l = mid + 1;
				}
				else
				{
					r = mid;
				}
			}
			cout << r << endl;
		}
	}
}


#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
struct student
{
	long long charge;
	long long usage;
	bool operator <(const student& r)const { return charge / usage > r.charge / r.usage; }
}s[200005];
int n, k;
bool judge(long long power)
{
	priority_queue<student> q;
	while (!q.empty()) q.pop();
	for (int i = 1; i <= n; i++)
	{
		q.push(student{ s[i].charge,s[i].usage });
	}
	student temp;
	for (int i = 1; i <= k; i++)
	{
		temp = q.top();
		q.pop();
		if (temp.charge / temp.usage < i - 1) return false;
		temp.charge += power;
		q.push(temp);
	}
	return true;
}
int main()
{
	while (cin >> n >> k)
	{
		for (int i = 1; i <= n; i++)cin >> s[i].charge;
		for (int i = 1; i <= n; i++) cin >> s[i].usage;
		if (judge(1e13) == false)
		{
			cout << -1 << endl;
			continue;
		}
		else
		{
			long long l = 0, r = 1e13;
			while (l < r)
			{
				long long mid = (l + r) >> 1;
				if (!judge(mid))
				{
					l = mid + 1;
				}
				else
				{
					r = mid;
				}
			}
			cout << r << endl;
		}
	}
}


#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
struct student
{
	long long charge;
	long long usage;
	bool operator <(const student& r)const { return charge / usage > r.charge / r.usage; }
}s[200005];
int n, k;
bool judge(long long power)
{
	priority_queue<student> q;
	while (!q.empty()) q.pop();
	for (int i = 1; i <= n; i++)
	{
		q.push(student{ s[i].charge,s[i].usage });
	}
	student temp;
	for (int i = 1; i <= k; i++)
	{
		temp = q.top();
		q.pop();
		if (temp.charge / temp.usage < i - 1) return false;
		temp.charge += power;
		q.push(temp);
	}
	return true;
}
int main()
{
	while (cin >> n >> k)
	{
		for (int i = 1; i <= n; i++)cin >> s[i].charge;
		for (int i = 1; i <= n; i++) cin >> s[i].usage;
		if (judge(1e18) == false)
		{
			cout << -1 << endl;
			continue;
		}
		else
		{
			long long l = 0, r = 1e18;
			while (l < r)
			{
				long long mid = (l + r) >> 1;
				if (!judge(mid))
				{
					l = mid + 1;
				}
				else
				{
					r = mid;
				}
			}
			cout << r << endl;
		}
	}
}


#include <iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
struct student
{
	long long charge;
	long long usage;
	bool operator <(const student& r)const { return charge / usage > r.charge / r.usage; }
}s[200005];
int n, k;
bool judge(long long power)
{
	priority_queue<student> q;
	while (!q.empty()) q.pop();
	for (int i = 1; i <= n; i++)
	{
		q.push(student{ s[i].charge,s[i].usage });
	}
	student temp;
	for (int i = 1; i <= k; i++)
	{
		temp = q.top();
		q.pop();
		if (temp.charge / temp.usage < i - 1) return false;
		temp.charge += power;
		q.push(temp);
	}
	if (q.top().charge / q.top().usage < k) return false;
	return true;
}
int main()
{
	while (scanf("%d%d",&n,&k)!=EOF)
	{
		for (int i = 1; i <= n; i++)scanf("%d", &s[i].charge);
		for (int i = 1; i <= n; i++) scanf("%d", &s[i].usage);
		if (judge(1e13) == false)
		{
			cout << -1 << endl;
			continue;
		}
		else
		{
			long long l = 0, r = 1e13;
			while (l < r)
			{
				long long mid = (l + r) >> 1;
				if (!judge(mid))
				{
					l = mid + 1;
				}
				else
				{
					r = mid;
				}
			}
			cout << r << endl;
		}
	}
}