【POJ】3273
来源:互联网 发布:程序员 杂志 编辑:程序博客网 时间:2024/05/18 00:53
http://poj.org/problem?id=3273
将N个权值分割成K个区间,使得每个区间的全职和的最大值最小。
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;int a[100000];int N,K;int l=0,r=0;int ans;int main(){ cin >> N >> K; for (int i=0;i<N;i++){ cin >> a[i]; r+=a[i]; l=max(l,a[i]); } while (l<r){ int mid=(l+r)>>1; int t=1; int cnt=0; for (int i=0;i<N;i++){ if (t+a[i]<=mid){ t+=a[i]; } else { cnt++; t=a[i]; } } if (cnt<K){ r=mid-1; } else l=mid+1; } cout << r << endl;}
阅读全文
0 0
- POJ 3273
- poj 3273
- poj 3273
- Poj 3273
- POJ 3273
- POJ-3273
- poj 3273
- POJ 3273
- poj 3273
- poj 3273
- POJ 3273
- POJ 3273
- 【POJ】3273
- poj 3273 Monthly Expense
- poj 3273 (二分)
- poj 3273(二分。。。很水。。。。)
- poj-3273 Monthly Expense
- poj 3273 二分法
- selenium iframe元素定位
- prompt set feedback set define的详解
- poi上传excel
- springMvc前后端传值
- 安装itk
- 【POJ】3273
- asm创建别名文件表空间,表空间删除后,数据文件需要手工删除测试
- rn笔记:关于navigator的初步理解
- android反编译错误代码 修正原则
- Eclipse使用Maven maven-artchetype-webapp创建Web2.5的Web项目
- Handler.postDelayed(new Runnable)是否运行在主线程
- CoreData兼容iOS9和iOS10_IOS_移动开发-ITnose
- JAVA-初步认识03-第一章命令行
- XZ_CSS之盒子模型