贪心算法求解多机调度问题

本文探讨如何利用贪心算法有效地分配7个独立作业到3台机器上进行处理,作业处理时间分别为2、14、4、16、6、5、3。通过贪心策略,优化资源分配,提高调度效率。
摘要由CSDN通过智能技术生成

有7个独立的作业(1,2,3,4,5,6,7),由3台机器(1,2,3)加工处理,各作业所需的处理时间分别为,2,14,4,16,6,5,3;

//
// Created by xzw12 on 2021/12/17.


#include <stdio.h>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <queue>

#define MAX 1001
using namespace std;
#define N 100
int n=7;
int m = 3;
struct NodeType {                           //优先队列节点类型
    int no;                                 //作业序号
    int t;                                  //执行时间
    int mono;                               //机器序号
    bool operator<(const NodeType &s)const
    {
        return t>s.t;                       //按t越小越优先出队
    }
};

void solve();

NodeType A[] ={
  {1, 2}, {2, 14}, {3, 4}, {4, 16}, {5, 6}, {6, 5}, {7, 3}};
int main(){
    printf("多机调度方案\n");
    solve();
}

void solve() {  
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值