
package Interview_Questions;
import java.util.*;

public class microsoft_1 {
    static void main() {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] req = new int[n];
        int[] stk = new int[n];
        int[] cos = new int[n];

        for(int i=0; i<n; i++){
            req[i] = sc.nextInt();
        }

        for(int i=0; i<n; i++){
            stk[i] = sc.nextInt();
        }

        for(int i=0; i<n; i++){
            cos[i] = sc.nextInt();
        }

        int bud = sc.nextInt();

        long low = 0;
        long high = 1000000000L;
        long ans = 0;

        while(low <= high){

            long mid = low + (high-low)/2;
            long tcos = 0;

            for(int i=0; i<n; i++){
                tcos += Math.max(0L,
                    ((long)req[i]*mid-stk[i])*cos[i]);
            }

            if(tcos > bud){
                high = mid-1;
            }
            else{
                ans = mid;
                low = mid+1;
            }

            System.out.println(mid+" "+tcos);
        }

        System.out.println(ans);
    }
}
