problemscpp
A collection of my answers to algorithm problems in c++.
静态 Public 成员函数 | 所有成员列表
leetcode::maximum_running_time_of_n_computers::Solution类 参考

#include <leetcode.h>

静态 Public 成员函数

static long long maxRunTime (int n, vector< int > &batteries)
 

详细描述

在文件 leetcode.h504 行定义.

成员函数说明

◆ maxRunTime()

long long leetcode::maximum_running_time_of_n_computers::Solution::maxRunTime ( int  n,
vector< int > &  batteries 
)
static

在文件 leetcode.cpp1098 行定义.

1098 {
1099 auto check = [&](long long t) {
1100 long long sum = 0;
1101 for(const int i: batteries) {
1102 sum += min(t, static_cast<long long>(i));
1103 }
1104 return sum / t >= n;
1105 };
1106
1107 long long l = 1;
1108 long long r = 1e16;
1109 while(l < r) {
1110 const long long m = (l + r) / 2;
1111 if(check(m)) {
1112 l = m + 1;
1113 } else {
1114 r = m;
1115 }
1116 }
1117 return l - 1;
1118 }

被这些函数引用 leetcode::maximum_running_time_of_n_computers::TEST().


该类的文档由以下文件生成: