1. 程式人生 > 其它 >element-ui 封裝table元件(自動填滿父容器高度,固定頭部滾動)

element-ui 封裝table元件(自動填滿父容器高度,固定頭部滾動)

#include <iostream>
#include <string>
#include <cmath>
#include <math.h>
#include <queue>
#include <algorithm>
#include <stack>
#include <vector>
#include <string.h>
#include <stdio.h>
using namespace std;
 
struct node
{
    int id;
    int
need; bool operator < (struct node tmp)const { return need < tmp.need; } }que[4][50010]; int n,m; int allo[4][50010]; int ava[4]; int outque[50010];//記錄每個程序出佇列的次數 int p[4]; bool solve() { int flag = 1; int i,j,k; int sum = 0; while(flag == 1) { flag = 0;
for(i = 1; i <= m; i++) //從第一個佇列開始列舉 { for( ; p[i] <= n; p[i]++) { if(ava[i] < que[i][p[i]].need) break; flag = 1; outque[ que[i][p[i]].id ]++; if(outque[ que[i][p[i]].id ] == m) //
當出隊次數等於m時,說明該程序可以執行 { sum++; for(j = 1; j <= m; j++) //更新vav[]。 ava[j] += allo[j][ que[i][p[i]].id ]; } } } } if(sum == n) return true; return false; } void debug() { for(int i = 1; i <= m; i++) { for(int j = 1; j <= n; j++) printf("i :%d need: %d ",que[i][j].id,que[i][j].need); printf("\n"); } } int main() { while(~scanf("%d %d",&n,&m)) { for(int i = 1; i <= m; i++) for(int j = 1; j <= n; j++) scanf("%d",&allo[i][j]); for(int i = 1; i <= m; i++) { for(int j = 1; j <= n; j++) { que[i][j].id = j; scanf("%d",&que[i][j].need); //先把每個程序對應的m個資源放進佇列 } } //debug(); for(int i = 1; i <= m; i++) { scanf("%d",&ava[i]); p[i] = 1; sort(que[i]+1,que[i]+1+n); //對每種資源按需求量升序排序 } //debug(); memset(outque,0,sizeof(outque)); if(solve()) printf("Yes\n"); else printf("No\n"); } return 0; }
View Code
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int N = 50005;
const int M = 5;
//N代表程序數,M代表資源
int all[N][M] ,req[N][M] ,res[M];
int vis[N];
 
int n,m;
bool judge(int i) {
    for(int j = 0; j < m; j++) {
        if(req[i][j] > res[j]) {
            return false;
        }
    }
    return true;
}
int main() {
    while(scanf("%d%d",&n,&m) != EOF) {
        for(int i = 0; i < m; i++) {
            for(int j = 0; j < n; j++) {
                scanf("%d",&all[j][i]);
            }
        }
 
        for(int i = 0; i < m; i++) {
            for(int j = 0; j < n; j++) {
                scanf("%d",&req[j][i]);
            }
        }
        for(int i = 0; i < m; i++) {
            scanf("%d",&res[i]);
        }
        int sum = 0 ,cnt;
        memset(vis,0,sizeof(vis));
        while(true) {
            cnt = 0;
            for(int i = n-1; i >= 0; i--) {
                if(!vis[i] && judge(i)) {
                    vis[i] = true;
                    for(int j = 0; j < m; j++) {
                        res[j] += all[i][j];
                    }
                    cnt++;
                }
            }
            sum += cnt;
            if(sum == n || cnt == 0) {
                break;
            }
        }
        if(sum == n) {
            printf("Yes\n");
        }else {
            printf("No\n");
        }
    }
    return 0;
}
View Code