-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
39 lines (33 loc) · 1.13 KB
/
Copy pathMain.java
File metadata and controls
39 lines (33 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package alibaba;
/**
* Created by liuyang on 17/4/1.
*/
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int maxQps = Integer.valueOf(in.nextLine());
final String[] rtList = in.nextLine().split(",");
final int requestNum = Integer.valueOf(in.nextLine());
final int threadNum = Integer.valueOf(in.nextLine());
System.out.println(doneTime(maxQps, rtList, requestNum, threadNum));
}
/**
* 如果使用最优的最大吞吐量负载均衡算法,按照最优模型多久能够处理完所有请求,单位毫秒。
*
* @return
*/
static long doneTime(int maxQps, String[] rtList, int requestNum, int threadNum) {
//TODO
int qpsSum = 0;
for (String str : rtList) {
int singleMaxQps = threadNum * 1000 / Integer.valueOf(str);
if (singleMaxQps > maxQps) {
qpsSum = qpsSum + maxQps;
} else {
qpsSum = qpsSum + singleMaxQps;
}
}
return requestNum / qpsSum * 1000;
}
}