题目描述
这天,小明在整理他的卡牌。
他一共有 n 种卡牌,第 i 种卡牌上印有正整数数 i(i ∈ [1, n]),且第 i 种卡牌 现有 ai 张。
而如果有 n 张卡牌,其中每种卡牌各一张,那么这 n 张卡牌可以被称为一 套牌。小明为了凑出尽可能多套牌,拿出了 m 张空白牌,他可以在上面写上数 i,将其当做第 i 种牌来凑出套牌。然而小明觉得手写的牌不太美观,决定第 i 种牌最多手写 bi 张。
请问小明最多能凑出多少套牌?
输入格式
输入共 3 行,第一行为两个正整数 n, m。
第二行为 n 个正整数 a1, a2, ..., an。
第三行为 n 个正整数 b1, b2, ..., bn。
输出格式
一行,一个整数表示答案。
样例输入
复制
4 5 1 2 3 4 5 5 5 5
样例输出
复制
3
import java.util.Scanner;
public class Main {
static int n;
static int a[], b[];
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
long m = sc.nextLong();
a = new int[n];
b = new int[n];
int min = Integer.MAX_VALUE;
int max