1. import java.io.*;
  2. import java.util.Arrays;
  3. public class Main {
  4. static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
  5. static PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
  6. static int n;
  7. static long m;
  8. static int max = 2 * 200010;
  9. static int[][] card;
  10. public static void main(String[] args) throws IOException {
  11. String[] input = bf.readLine().split(" ");
  12. n = Integer.parseInt(input[0]);
  13. m = Long.parseLong(input[1]);
  14. card = new int[2][n];
  15. for (int i = 0; i < 2; i++) {
  16. input = bf.readLine().split(" ");
  17. for (int j = 0; j < n; j++) {
  18. card[i][j] = Integer.parseInt(input[j]);
  19. }
  20. }
  21. int l = 0, r = max;
  22. while (l < r) {
  23. int mid = (l + r + 1) / 2;
  24. if (check(mid)) {
  25. l = mid;
  26. } else {
  27. r = mid - 1;
  28. }
  29. }
  30. out.println(l);
  31. out.flush();
  32. out.close();
  33. }
  34. public static boolean check(int num) {
  35. int blank_num = 0;
  36. for (int i = 0; i < n; i++) {
  37. if (card[0][i] < num) {
  38. if (card[0][i] + card[1][i] < num) return false;
  39. blank_num += num - card[0][i];
  40. }
  41. }
  42. return blank_num <= m;
  43. }
  44. }
点赞(0)
 

9.9 分

1 人评分

 

C语言网提供由在职研发工程师或ACM蓝桥杯竞赛优秀选手录制的视频教程,并配有习题和答疑,点击了解:

一点编程也不会写的:零基础C语言学练课程

解决困扰你多年的C语言疑难杂症特性的C语言进阶课程

从零到写出一个爬虫的Python编程课程

只会语法写不出代码?手把手带你写100个编程真题的编程百练课程

信息学奥赛或C++选手的 必学C++课程

蓝桥杯ACM、信息学奥赛的必学课程:算法竞赛课入门课程

手把手讲解近五年真题的蓝桥杯辅导课程

评论列表 共有 0 条评论

暂无评论