第二题优先队列过的 Arrays.sort(arr); Queue<Integer> q = new PriorityQueue<>(); for(int i = 1;i<n;i++){ q.add(arr[i]-arr[i-1]); } q.add(Integer.MAX_VALUE);//最后一个工人不受限制 int f = k; while(f>0){ int x = q.peek(); if(x*q.size()<f){ f-=x; q.poll(); }else{ int s = q.size(); int ans = f/s+(f%s==0?0:1); System.out.println(ans); return; } }
点赞 评论

相关推荐

11-11 16:40
已编辑
门头沟学院 人工智能
不知道怎么取名字_:这个有点不合理了,相当于已经毕业了,但还是没转正,这不就是白嫖
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务