unittest
{
	assert( [ "3 5", "4 2 1", "2 3 1" ].solve == 2 );
	assert( [ "3 8", "4 2 1", "2 3 1" ].solve == 0 );
	assert( [ "11 14", "3 1 4 1 5 9 2 6 5 3 5", "8 9 7 9 3 2 3 8 4 6 2" ].solve == 12 );
}



import std.algorithm;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto k = 0L;
	input.front.formattedRead!"%s %s"( n, k );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	input.popFront;
	auto fs = input.front.split.to!( long[] );
	
	// かかる時間が平均化するように並べ替え
	as.sort!( ( x, y ) => y < x );
	fs.sort;
	
	// k回までの修行で全員が完食できる時間を二分探索
	auto e( long x )
	{
		auto t = 0L;
		foreach( a, f; lockstep( as, fs ) )
		{
			t += ( max( 0L, a * f - x ) + f - 1 ) / f;
			if( k < t ) return false;
		}
		return true;
	}
	return bisect!e( -1L, as.front * fs.back );
}

// 単調増加or減少関数の二分探索
auto bisect( alias pred )( long ng, long ok )
if( is( typeof( pred( ng ) ) : bool ) )
{
	while( 1 < abs( ok - ng ) )
	{
		auto x = ( ok + ng ) / 2;
		if( pred( x ) ) ok = x;
		else            ng = x;
	}
	return ok;
}

