Drying
来源:互联网 发布:德国pjur怎么样 知乎 编辑:程序博客网 时间:2024/06/03 23:39
Drying
Time Limit : 4000/2000ms (Java/Other) Memory Limit : 131072/65536K (Java/Other)
Total Submission(s) : 93 Accepted Submission(s) : 30
It is very hard to wash and especially to dry clothes in winter. But Jane is a very smart girl. She is not afraid of this boring process. Jane has decided to use a radiator to make drying faster. But the radiator is small, so it can hold only one thing at a time.
Jane wants to perform drying in the minimal possible time. She asked you to write a program that will calculate the minimal time for a given set of clothes.
There are n clothes Jane has just washed. Each of them took ai water during washing. Every minute the amount of water contained in each thing decreases by one (of course, only if the thing is not completely dry yet). When amount of water contained becomes zero the cloth becomes dry and is ready to be packed.
Every minute Jane can select one thing to dry on the radiator. The radiator is very hot, so the amount of water in this thing decreases by k this minute (but not less than zero — if the thing contains less than k water, the resulting amount of water will be zero).
The task is to minimize the total time of drying by means of using the radiator effectively. The drying process ends when all the clothes are dry.
<b>sample input #1</b>32 3 95<b>sample input #2</b>32 3 65
<b>sample output #1</b>3<b>sample output #2</b>2题意:有n件衣服 每一件晒有一个湿度,干需要一定时间,给出每分钟可以烘干的湿度,如果不烘干,则每分钟靠蒸发湿度-1,烘干的时候不蒸发 问吧这下衣服弄干的最短的时间思路: 首先注意费就是数据,要longlong ,而且cin超时对于烘干的速度是1 则不用多说,湿度最大的就是最慢的其他情况 最快的方法也比较容易想,先举出一个时间数值,比这个数小的可以自己蒸发,不用管他们,其余的就是先烘干一会,然后在烘干其他衣服是,之前烘过的蒸发干了判断当前mid分钟内是否完场就行了推断 对于每一件衣服 k*t+(mid-t)>=map[i,得到t>=(map[i]–mid)/(k–1)#include<iostream>#include<cmath>#include<stdio.h>using namespace std;long long n,k;long long map[1000001];int judge(long long mid){ long long temp,t=0; for(int i=0;i<n;i++) { if(map[i]>mid) { temp=(long long)ceil((map[i]-mid)*1.0/(k-1)); t+=temp; } if(t>mid)return 0; } return 1; }int main(){ int i,j; long long max; char s[100]; while(scanf("%lld",&n)!=EOF) { max=0; for(i=0;i<n;i++) { scanf("%lld",&map[i]); if(max<map[i]) max=map[i]; } scanf("%lld",&k); if(k==1) { cout<<max<<endl; } else { long long ans,mid,low=1,high=max; while(low<=high) { mid=(low+high)/2; if(judge(mid)) { ans=mid; high=mid-1; } else low=mid+1; } //cout<<s<<endl; cout<<ans<<endl; } } return 0; }
- Drying
- Drying
- Drying
- Drying
- POJ3104 Drying
- POJ Drying
- POJ3104 Drying
- POJ3104--Drying
- POJ3104-Drying
- POJ3104 Drying
- POJ3104-Drying
- Drying POJ
- Drying POJ
- Drying POJ
- POJ 3104 Drying 二分
- 二分法 POJ-3104 Drying
- POJ--3104--Drying【二分】
- POJ 3104 Drying
- ReactNative 退出到后台一定时间之后,跳转到登录界面
- Linux team 及网桥
- 士兵杀敌(三) 【nyoj-119】【线段树】
- 南理 奇偶数分离
- 问题 B: 黑色星期五
- Drying
- 《剑指offer》牛客网java题解
- PHP对程序员的要求更高
- 士兵杀敌(三)(线段树)
- 网易2018校招编程题集合3
- Linux下搭建 NFS
- 基于Cesium剖面分析功能的实现
- 无向图的遍历(BFS+DFS,MATLAB)
- LVM(逻辑卷管理)