链接:

https://www.luogu.org/problemnew/show/P1541

【思路】:

用f[a][b][c][d]表示,第一张卡用a张,第二张卡用b张..........然后就盘就ok了

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<string>
#include<cstring>
using namespace std;
const int maxn=;
const int minn=-;
inline int read() {
char c = getchar();
int x = , f = ;
while(c < '' || c > '') {
if(c == '-') f = -;
c = getchar();
}
while(c >= '' && c <= '') x = x * + c - '', c = getchar();
return x * f;
}
int n,m,a[],f[][][][],s[],js[],b;
int main() {
cin>>n>>m;
for(int i=; i<=n; ++i) {
a[i]=read();
}
for(int i=; i<=m; ++i) {
cin>>b;
js[b]++;
}
f[][][][]=a[];
for(int i=; i<=js[]; ++i) {
for(int j=; j<=js[]; ++j) {
for(int k=; k<=js[]; ++k) {
for(int l=; l<=js[]; ++l) {
int place=+i*+j*+k*+l*;
if(i!=) {
f[i][j][k][l]=max(f[i][j][k][l],f[i-][j][k][l]+a[place]);
}
if(j!=) {
f[i][j][k][l]=max(f[i][j][k][l],f[i][j-][k][l]+a[place]);
}
if(k!=) {
f[i][j][k][l]=max(f[i][j][k][l],f[i][j][k-][l]+a[place]);
}
if(l!=) {
f[i][j][k][l]=max(f[i][j][k][l],f[i][j][k][l-]+a[place]);
}
}
}
}
}
cout<<f[js[]][js[]][js[]][js[]];
return ;
}

最新文章

  1. 解决TalbleView头部或底部子控件不显示问题
  2. PHP函数篇详解十进制、二进制、八进制和十六进制转换函数说明
  3. 刀哥多线程Barrier异步gcd-08-barrier_async
  4. 简单易用的AOP/IOC框架
  5. jQuery 源码分析4: jQuery.extend
  6. windows下删除服务的方法
  7. 宣布发布 Windows Azure ExpressRoute,宣告与 Level 3 建立全新的合作伙伴关系并推出关于其他 Azure 服务令人振奋的更新
  8. debian6 更新python版本到python3.3
  9. 转:web_url函数学习
  10. Spring之Core模块
  11. YSLOW(一款实用的网站性能检测工具)
  12. Confluence 6 开始编辑 CSS
  13. PHP 二位数组按照下标排序
  14. PHP 扩展 MongoDB
  15. 洛谷P1074 靶形数独【dfs】【剪枝】
  16. SSM事务——事务回滚如何拿到返回值
  17. laravel 批量更新
  18. Centos crontab定时任务
  19. utime修改文件的存取,修改时间
  20. elastic search报错——“failed to obtain node locks”

热门文章

  1. zipkin的安装与搭建
  2. Java泛型 - 返回父类的子类
  3. Apach Shiro MD5密码加密过程(明文生成密码过程)详细解析
  4. pytorch learning rate decay
  5. Crontab详细用法-定时任务详解
  6. jquery easyui datagrid 在翻页以后仍能记录被选中的行及刷新设置选中行数据
  7. 扩展JS
  8. Python接口自动化基础---get请求
  9. Celery定时任务细讲
  10. vue动态加载图片