当前位置:网站首页>User scheduling problem
User scheduling problem
2022-06-25 17:42:00 【Python Encyclopedia】
■ Title Description
A positive integer array is given to represent the task list to be executed by the system , Each element of the array represents a task , The value of the element indicates the type of the task .
Please calculate the minimum time required to complete all tasks .
The task execution rules are as follows :
Tasks can be executed in any order , And the execution time of each task is 1 Time units .
Two tasks of the same type must have a length of N Cooling time of units , such as N by 2 when , In time K Type executed 3 The task of , that K+1 and K+2 Two time cannot execute type 3 Mission .
The system can perform a task in any unit of time , Or waiting state .
explain : The maximum length of the array is 1000, Maximum speed 1000.
Input description
The first line records an array separated by half width commas , Array length not more than 1000, The value of the array element does not exceed 1000,
The second line records the task cooling time ,N As a positive integer ,N<=100.
Output description
The output is the minimum time required to complete all tasks .
Example 1 Input and output examples are for debugging only , The background judgment data generally does not contain examples
Input
2,2,2,3
2
Output
7
explain
Time 1: Execution type 2 Mission .
Time 2: Execution type 3 The task of ( Because the cooling time is 2, So time 2 Cannot execute type 2 The task of ).
Time 3: The system waits ( Still in type 2 The cooling time of ).
Time 4: Execution type 2 Mission .
Time 5: The system waits .
Time 6: The system waits .
Time 7: Execution type 2 Mission .
So it takes a total of 7.
def task_schedule():
arr = input().strip().split(",")
n = int(input().strip())
d = {
}
d_max = 0
d_max_n = 0
for i in arr:
d[i] = d.get(i, 0) + 1
if d[i] > d_max:
d_max = d[i]
for k, v in d.items():
if d[k] == d_max:
d_max_n += 1
return max((d_max - 1) * (n + 1) + d_max_n, len(arr))
if __name__ == "__main__":
print(task_schedule())
边栏推荐
- ACY100油烟浓度在线监控仪针对饮食业厨房油烟排放
- Win10开启热点共享后断网怎么解决?
- [compilation principle] lexical analysis
- Essential characteristics of convolution operation +textcnn text classification
- 数学建模——非线性规划
- 【Matlab】数据统计分析
- golang sort slice int
- 中断操作:AbortController学习笔记
- Golang sort slice int
- Super Full Metal PBR Multi - channel Mapping Materials website collation
猜你喜欢

学习太极创客 — MQTT(二)MQTT 基本原理

杰理之获取复位源和唤醒的 IO 口的方法【篇】

数学建模——非线性规划

Uncover ges super large scale graph computing engine hyg: Graph Segmentation

SDN system method | 10 The future of SDN

How high does UART baud rate require for clock accuracy?

What are the steps for launching the mobile ERP system? It's important to keep it tight

相同wifi下,笔记本连接台式机上的虚拟机
![[black apple] Lenovo Savior y70002019pg0](/img/9c/7a94aa911dd0c6b94ba192bc2687e6.png)
[black apple] Lenovo Savior y70002019pg0

How does LSF see whether the job reserved slot is reasonable?
随机推荐
How high does UART baud rate require for clock accuracy?
十大龙头券商 办理开户安全吗
Assembly language (5) register (memory access)
Sentinel哨兵机制
CVPR small target detection: context and attention mechanisms improve small target detection (attached with paper Download)
[matlab] data statistical analysis
Can I open an account? Is it safe to open an account
bert之我的小总结
Huawei cloud gaussdb (for redis) unveiling issue 19: gaussdb (for redis) comprehensive comparison with CODIS
使用DiskGenius拓展系统盘C盘的容量
jupyter的使用
Mathematical modeling - linear programming
The second round of Yunnan Cyberspace Security competition in May 2021
用户调度问题
杰理之如何给外界输出一个时钟源使用【篇】
conda 修改镜像源
What is public chain development? What are the public chain development projects?
js禁止浏览器默认事件
Distributed remote management of distribution room environment
【Matlab】数值微积分与方程求解