• P1065 作业调度方案


    一道傻逼模拟写了半个小时还wa了一次
    我退役罢

    #include <cstdio>
    #include <cstring>
    #include <cassert>
    #include <iostream>
    #include <algorithm>
    using namespace std;
    const int MAXN = 20 + 5;
    inline int read(){
    	char ch = getchar(); int x = 0;
    	while(!isdigit(ch)) ch = getchar();
    	while(isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
    	return x;
    }
    
    int N, M;
    int a[MAXN * MAXN];
    int idx[MAXN][MAXN], val[MAXN][MAXN];
    
    int p[MAXN], ti[MAXN];
    bool vis[MAXN][MAXN * MAXN];
    
    inline bool ok(int &st, int &len, int &mac) {
    	for(int i = st; i <= st + len - 1; i++) 
    		if(vis[mac][i]) return false;
    	for(int i = st; i <= st + len - 1; i++) vis[mac][i] = true;
    	return true;
    }
    
    int main(){
    	// freopen("p1065.in", "r", stdin);
    	cin>>M>>N;
    	for(int i = 1; i <= N * M; i++) a[i] = read();
    	for(int i = 1; i <= N; i++)
    		for(int j = 1; j <= M; j++) idx[i][j] = read();
    	for(int i = 1; i <= N; i++)
    		for(int j = 1; j <= M; j++) val[i][j] = read();
    
    	for(int i = 1; i <= N * M; i++) {
    		++p[a[i]]; int &t = ti[a[i]];
    		while(!ok(t, val[ a[i] ][ p[a[i]] ], idx[ a[i] ][ p[a[i]] ])) ++t;
    		t += val[ a[i] ][ p[a[i]] ];
    	}
    
    	int ans = 0;
    	for(int i = 1; i <= N; i++) ans = max(ans, ti[i]); 
    		
    	printf("%d
    ", ans);
    	return 0;
    }
    
    
  • 相关阅读:
    练习4.22、4.23、4.24
    练习4.20
    练习4.17、4.18、4.19
    mysql基础语句
    mysql的innodb存储引擎
    git
    mysql集群7.4.1
    批量执行命令
    cnetos 7 mariadb 集群报错分析解答
    windows_agent 添加
  • 原文地址:https://www.cnblogs.com/wsmrxc/p/9781806.html
Copyright © 2020-2023  润新知