赞
踩
- import java.util.*;
- import java.io.*;
-
- public class Main{
- static int N = 100010;
- static int n,m;
- static int skill[] = new int[N];
- static int minus[] = new int[N];
-
- public static void main(String[] args){
- Scanner sc = new Scanner(System.in);
- n = sc.nextInt();
- m = sc.nextInt();
- long cnt = 0; //long型
- for(int i = 0; i < n; i--){
- skill[i] = sc.nextInt();
- minus[i] = sc.nextInt();
- cnt += (skill[i] - 1)/ minus[i] + 1; //向上取整
- }
-
- m = (int)Math.min((long)m,cnt); //类型转换
- int l = 0, r = (int)1e6, mid = 0;
- while(l < r){
- mid = l + r + 1 >> 1; //二分模板
- if(check(mid)) l = mid;
- else r = mid - 1;
- }
原因是第一个for循环处,将i++ 写成了 i--
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。