#include <bits/stdc++.h>
#define ll long long
using namespace std;
struct data{
int a[25]; //工序的操作位置
int b[25]; //对应操作时间
int ab=0; //当前进行到哪项工序
int t[25]; //对每道工序完成时所处的时间
};
int c[405];
struct data gj[25];
bool bn[21][37777]; //在当前时间是否空挡
int main(){
int n,m;
cin>>m>>n;
for(int i=1;i<=m*n;i++){ //给定安排顺序
cin>>c[i];
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++)
cin>>gj[i].a[j];
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++)
cin>>gj[i].b[j];
}
int ans = 0; //时间线
for(int i=1;i<=n*m;i++){
int count = 0;
for(int j=gj[c[i]].t[gj[c[i]].ab]+1;j<25*25;j++){
if(bn[gj[c[i]].a[gj[c[i]].ab+1]][j]==false)
count++;
else
count = 0;
if(count>=gj[c[i]].b[gj[c[i]].ab+1]){
for(int k=gj[c[i]].t[gj[c[i]].ab]+1;k<=j;k++){
bn[gj[c[i]].a[gj[c[i]].ab+1]][k] = true;
}
gj[c[i]].ab++;
gj[c[i]].t[gj[c[i]].ab] = j;
break;
}
}
}
for(int i=1;i<=m;i++){
int max = 0;
for(int j=0;j<405;j++)
if(bn[i][j])
max = j;
if(max>ans)
ans = max;
// cout<<max<<endl;
}
cout<<ans;
return 0;
}
```测试点1 7 8 9过不了,求大佬指点迷津