zoukankan      html  css  js  c++  java
  • 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;
    }
    
    
  • 相关阅读:
    实现Email传送
    用角色来管理权限
    最大在线人数统计
    解决DataGrid显示时间格式问题
    3秒后自动跳转
    ASP.NET页面的处理顺序
    乱码问题
    动态生成button并关联其onclick事件
    获取用户计算机信息
    鼠标滚轮缩放图片(js)
  • 原文地址:https://www.cnblogs.com/wsmrxc/p/9781806.html
Copyright © 2011-2022 走看看