有人能帮我下载一下数据6吗
查看原帖
有人能帮我下载一下数据6吗
801434
TYUT_Raven楼主2022/9/24 18:09
#include<iostream>
#include<cstring>
#include<queue>
using namespace std;

int order[400]; bool storder[400]; 
int cnt=0;
bool status[21][10000];
int statusNum[21];

struct Obj
{
    queue<int> time;//工件对应机器对应消耗的时间
    queue<int> machine;//工件对应机器
    int canBePlace = 1;
} obj[21];

int main()
{
    int m, n; cin >> m >> n;//n个工件 m个机器
    for (int i = 0; i < m * n; i++) { cin >> order[i]; storder[i] = true; cnt++; }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < m; j++) {
            int t; cin >> t;
            obj[i].machine.push(t);
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < m; j++) {
            int t; cin >> t;
            obj[i].time.push(t);
        }
    }


    //while (cnt)
    
        for (int i = 0; i < m * n; i++)
        {
            if (storder[i])
            {
                int t = order[i];
                storder[i] = false; cnt--;
                int machine = obj[t].machine.front(); obj[t].machine.pop();//肯定是可以找到地方,所以直接弹出
                int time = obj[t].time.front(); obj[t].time.pop();

                int cnt2 = 0, tmp = 0;
                for (int j = obj[t].canBePlace; j <= 10000; j++)
                {
                    if (!status[machine][j]) cnt2++;
                    else cnt2 = 0;
                    if (cnt2 >= time) { tmp = j; break; }
                }
                obj[t].canBePlace = tmp + 1;
                statusNum[machine] = tmp;
                for (;cnt2>0;cnt2--,tmp--) status[machine][tmp] = true;
            }
        }
    
    int res = 0;
    for (auto i : statusNum) res = max(res, i);
    cout << res;
}

为啥这个代码死活过不了数据6

2022/9/24 18:09
加载中...