poj 3273 Monthly Expense
来源:互联网 发布:linux装vim 编辑:程序博客网 时间:2024/05/21 12:56
http://poj.org/problem?id=3273
解题思路:
#include <cstdio>#include <cstring>#include <algorithm>using namespace std;#define max 100001int day[max];int n,m;int main(){ int i,j; int sum,cnt,ma,low,high,mid; while(~scanf("%d %d",&n,&m)) { memset(day,0,sizeof(day)); sum=0; ma=0; for(i=0;i<n;i++) { scanf("%d",&day[i]); if(day[i]>ma) { ma=day[i]; } sum+=day[i]; } low=ma; high=sum; while(low<=high) { mid=(low+high)/2; sum=0; cnt=1; for(i=0;i<n;i++) { sum+=day[i]; if(sum>mid) { sum=day[i]; cnt++; } } if(cnt<=m) { ma=mid; high=mid-1; } else low=mid+1; } printf("%d\n",ma); } return 0;}
0 0
- poj 3273 Monthly Expense
- poj-3273 Monthly Expense
- poj 3273 Monthly Expense
- poj 3273 Monthly Expense
- POJ 3273 Monthly Expense
- POJ 3273 Monthly Expense
- POJ 3273 Monthly Expense
- POJ 3273 Monthly Expense
- POJ-3273-Monthly Expense
- POJ 3273 Monthly Expense
- poj 3273 Monthly Expense
- POJ 3273 Monthly Expense
- poj 3273 Monthly Expense
- POJ 3273 Monthly Expense
- POJ 3273 Monthly Expense
- POJ - 3273 Monthly Expense
- POJ-3273-Monthly Expense
- POJ 3273 Monthly Expense
- Laravel数据库操作的三种方式
- Python ssh登录并且执行命令
- 《Hibernate》------二级缓存
- linux系统Mysql5.6下载与安装
- wwWFrank2的Android学习之路一(开启Android之路)
- poj 3273 Monthly Expense
- HTML、CSS知识点总结。
- 从0到阿里
- 基于XML文件的客户端校验
- MySQL 列类型-数值型
- updates were rejected because the tip of your current branch is behind its remote counterpart
- STM32开发环境搭建和固件烧录
- poj 3624 Charm Bracelet (01背包 基础)
- session详解