zoukankan      html  css  js  c++  java
  • LuoguP5322 [BJOI2019]排兵布阵(DP)

    城为物,人为容,价值?排序后,一切都明了

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <cstdlib>
    #include <algorithm>
    #include <cmath>
    #define R(a,b,c) for(register int a = (b); a <= (c); ++a)
    #define nR(a,b,c) for(register int a = (b); a >= (c); --a)
    #define Fill(a,b) memset(a, b, sizeof(a))
    #define Swap(a,b) ((a) ^= (b) ^= (a) ^= (b))
    #define QWQ
    #ifdef QWQ
    #define D_e_Line printf("
    ---------------
    ")
    #define D_e(x) cout << (#x) << " : " << x << "
    "
    #define Pause() system("pause")
    #define FileOpen() freopen("in.txt", "r", stdin)
    #define FileSave() freopen("out.txt", "w", stdout)
    #define TIME() fprintf(stderr, "
    TIME : %.3lfms
    ", clock() * 1000.0 / CLOCKS_PER_SEC)
    #else
    #define D_e_Line ;
    #define D_e(x) ;
    #define Pause() ;
    #define FileOpen() ;
    #define FileSave() ;
    #define TIME() ;
    #endif
    struct ios {
    	template<typename ATP> inline ios& operator >> (ATP &x) {
    		x = 0; int f = 1; char c;
    		for(c = getchar(); c < '0' || c > '9'; c = getchar()) if(c == '-') f = -1;
    		while(c >= '0' && c <='9') x = x * 10 + (c ^ '0'), c = getchar();
    		x *= f;
    		return *this;
    	}
    }io;
    using namespace std;
    template<typename ATP> inline ATP Max(ATP a, ATP b) {
    	return a > b ? a : b;
    }
    template<typename ATP> inline ATP Min(ATP a, ATP b) {
    	return a < b ? a : b;
    }
    template<typename ATP> inline ATP Abs(ATP a) {
    	return a < 0 ? -a : a;
    }
    
    const int N = 107;
    
    int f[20007], a[N][N];
    
    int main() {
    	int s, n, m;
    	io >> s >> n >> m;
    	R(i,1,s){
    		R(j,1,n){
    			io >> a[j][i];
    		}
    	}
    	R(i,1,n){
    		sort(a[i] + 1, a[i] + s + 1);
    	}
    	R(i,1,n){
    		nR(j,m,0){
    			R(k,1,s){
    				if(j >= (a[i][k] << 1 | 1)){
    					f[j] = Max(f[j], f[j - ((a[i][k] << 1 | 1))] + k * i);
    				}
    			}
    		}
    	}
    	int ans = 0;
    	R(i,0,m) ans = Max(ans, f[i]);
    	printf("%d", ans);
    	return 0;
    } 
    

  • 相关阅读:
    Swift和OC混编
    Excel数据导入___你hold住么(一)
    Cocos2d-x 3.0多线程异步资源载入
    FPGA实现网络通信时的网络字节序问题
    easyui datagrid 动态加入、移除editor
    struts.xml中出现extends undefined package struts-default解决的方法
    Maven入门
    后面需要继续完善的地方
    CentOS6.9 安装OpenResty
    数据库异步写入功能概要设计
  • 原文地址:https://www.cnblogs.com/bingoyes/p/11743429.html
Copyright © 2011-2022 走看看