解题思路:
注意事项:
参考代码:
宏伟的程序,我自己看的都头疼:
#include <iostream> #define maxn 50 using namespace std; int n,m; int ans = 0; int worklist[maxn * maxn]; int worknumber[maxn][maxn]; int worktime[maxn][maxn]; int cnt_now_work_step[maxn]; int lasttime[maxn]; bool timeline[maxn * maxn][maxn * maxn]; bool check_in_line(int begin_time_point,int end_time_length,int workid){ for (int time = begin_time_point; time <= end_time_length;time++) if (timeline[workid][time]) return false; return true; } int main(){ cin >> m >> n; for (int i=1;i<=n*m;i++) cin >> worklist[i]; for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) cin >> worknumber[i][j]; for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) cin >> worktime[i][j]; for (int i=1;i<=n*m;i++){ int nowitem = worklist[i]; cnt_now_work_step[nowitem]++;//工序数 int nownumber = worknumber[nowitem][cnt_now_work_step[nowitem]]; int costtime = worktime[nowitem][cnt_now_work_step[nowitem]]; for (int time = lasttime[nowitem]+1;;time++)//扫描时间轴 if (check_in_line(time,time+costtime-1,nownumber)){ for (int marktime = time;marktime <= time+costtime-1;marktime++) timeline[nownumber][marktime] = true; lasttime[nowitem] = time + costtime - 1; break; } } for (int i=1;i<=n;i++) ans = max(ans,lasttime[i]); cout << ans << endl; return 0; }
0.0分
26 人评分
模拟计算器 (C语言代码)浏览:966 |
Biggest Number (C++代码)回溯法浏览:1676 |
简单的a+b (C语言代码)浏览:583 |
WU-printf基础练习2 (C++代码)浏览:2061 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:648 |
C语言程序设计教程(第三版)课后习题1.6 (C语言代码)浏览:524 |
C二级辅导-公约公倍 (C语言代码)浏览:537 |
分糖果 (C语言代码)浏览:980 |
C语言训练-自守数问题 (C语言代码)浏览:798 |
多输入输出练习2 (C语言代码)浏览:1709 |