1 solutions
-
0
模拟
依次处理每个工件的每个顺序,对于在当前机器上找到最前面的可以插入的点即可。
#include<bits/stdc++.h> using namespace std; typedef pair<int,int> PII; #define x first #define y second const int N=25,M=N*N,INF=1e9; int m,n; int q[M],last[N],cnt[N]; int g[N][N],w[N][N]; vector<PII> mch[N]; int main() { cin>>m>>n; for(int i=1;i<=n*m;i++) //获取安排序列 { cin>>q[i]; } for(int i=1;i<=n;i++) //获取安排 { for(int j=1;j<=m;j++) { cin>>g[i][j]; } } for(int i=1;i<=n;i++) //获取完成时间 { for(int j=1;j<=m;j++) { cin>>w[i][j]; } } for(int i=1;i<=m;i++) //设置哨兵 { mch[i].push_back({0,0}); mch[i].push_back({INF,INF}); } int res=0; for(int i=1;i<=n*m;i++) { int t=q[i],c=++cnt[t];//获取当前工件和工件的序号 int len=w[t][c]; //获取当前工件的时间 auto& machine=mch[g[t][c]];//获取当前工件的加工的机器状态 for(int j=0,end=last[t];;j++) { end=max(end,machine[j].y); //机器的每个任务的结束时间和当前工件的上个序列的结束时间的最大值 if(machine[j+1].x-end>=len) //空余的时间可以放置当前工件 { machine.push_back({end,end+len}); sort(machine.begin(),machine.end()); last[t]=end+len; //更新当前工件的结束时间 res=max(res,last[t]);//更新当前工件的结束时间 break; } } } cout<<res; return 0; }
- 1
Information
- ID
- 452
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- 5
- Tags
- # Submissions
- 1
- Accepted
- 1
- Uploaded By