V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  zoyao  ›  全部回复第 5 页 / 共 5 页
回复总数  85
1  2  3  4  5  
163
分母+++
之前了解过,奥园质量堪忧,外墙瓷砖脱落还砸伤过人,坐标广州
复杂度应该是 O(N),v2ex 不支持 markdown 呀
```
/**
* @author zoyao.
* @create 2022/2/11
* @param a 自然烘干每单位时间烘干湿度
* @param b 机器烘干每单位时间烘干湿度
* @param cloths 所有待烘干衣服
* @return
*/
public double dry(int a, int b, int[] cloths) {
Arrays.sort(cloths);
long total = Arrays.stream(cloths).sum();
double hourMin = cloths[cloths.length - 1];
//假设烘干时间在 cloths[i-1]至 cloths[i]之间
for (int i = 0; i < cloths.length; i++) {
int cloth = cloths[i];
//只计算所有湿度大于等于 cloths[i-1]的衣服
//自然烘干:a * (cloths.length - i) * hour
//机器烘干:b * hour
double hour = (double) total / (a * (cloths.length - i) + b);
total -= cloth;
//不满足上述假设条件
if (hour > cloth || (i > 0 && hour < cloths[i - 1])) {
continue;
}
if (hour < hourMin) {
hourMin = hour;
}
}
return hourMin;
}
```
1  2  3  4  5  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2365 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 32ms · UTC 12:00 · PVG 20:00 · LAX 05:00 · JFK 08:00
Developed with CodeLauncher
♥ Do have faith in what you're doing.