水——洛谷P1065 作业调度方案

洛谷1065题解析
本文提供洛谷1065题的详细解答方案,通过直接模拟的方法完成题目要求,并介绍了具体实现代码,适合用于提升编程技巧及读题能力。

https://www.luogu.org/problem/show?pid=1065
题目读懂直接模拟就好了;
其实没什么必要刷这种题目,训练读题能力直接做高级数论就好了;
另外time[][]会重名

#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
#include<algorithm>
#define Ll long long 
using namespace std;
int a[10000],now,x,y;
int num[25][25],t[25][25],tot[25];
int v[25][10000],l,sum,top[25];
int n,m,ans;
int main()
{
    scanf("%d%d",&m,&n);
    for(int i=1;i<=n*m;i++)scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)scanf("%d",&num[i][j]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)scanf("%d",&t[i][j]);
    while(now<n*m){
        now++;
        x=a[now];
        tot[x]++;
        y=t[x][tot[x]];
        x=num[x][tot[x]];
        l=top[a[now]]+1;sum=0;
        for(int i=top[a[now]]+1;;i++){
            if(v[x][i-1]&&!v[x][i])l=i;
            if(!v[x][i])sum++;else sum=0;
            if(sum==y)break;
        }
        for(int i=1;i<=y;i++)v[x][l+i-1]=1;
        top[a[now]]=l+y-1;
        ans=max(ans,l+y-1);
    }
    printf("%d",ans);
}

转载于:https://www.cnblogs.com/largecube233/p/6797841.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值