一般这种要倒着来。

#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define PII pair<int, int>
#define y1 skldjfskldjg
#define y2 skldfjsklejg using namespace std; const int N = 1e5 + ;
const int M = 1e7 + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = ; int n, m, cur, x, up, a[N], f[][ << ], op[], cnt[ << ];
char t[][]; int dp(int x, int s) {
if(s == up - ) return ;
if(f[x][s] != inf) return f[x][s];
f[x][s] = op[x] == ? -inf : inf;
for(int j = ; j < n; j++) {
if((s >> j) & ) continue;
int add = t[x][] == 'p' ? a[j] : ;
if(op[x] == ) f[x][s] = max(f[x][s], dp(x + , s | ( << j)) + add);
else f[x][s] = min(f[x][s], dp(x + , s | ( << j)) - add);
}
return f[x][s];
} int main() {
memset(f, inf, sizeof(f));
scanf("%d", &n);
for(int i = ; i < n; i++) scanf("%d", &a[i]);
sort(a, a + n); reverse(a, a + n);
scanf("%d", &m); n = min(n, m); up = << n; for(int i = ; i < m; i++)
scanf("%s%d", t[i], &op[i]); printf("%d\n", dp(, ));
return ;
} /*
*/

最新文章

  1. Deployment options
  2. Atitit java方法引用(Method References)&#160;与c#委托与脚本语言js的函数指针
  3. zabbix使用tokudb引擎替换innodb引擎
  4. URAL 1002 Phone Numbers(KMP+最短路orDP)
  5. VS2012创建MVC3项目提示错误: 此模板尝试加载组件程序集 “NuGet.VisualStudio.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”。
  6. 适配iOS9遇到的一些问题_Scheme白名单_ Bitcode及解决办法
  7. 再次深入理解delphi的类
  8. 【Python开发实战】Python环境的配置
  9. UI基础 - UIScrollView
  10. Hibernate整合Struts2时报错
  11. 【转】Directx11 HelloWorld之HLSL的Effect框架的使用
  12. 用邻接表或vector实现存边以及具体如何调用[模板]
  13. 201521123072《java程序设计》第五周学习总结
  14. pipelineDB初体验
  15. [译]Ocelot - Claims Transformation
  16. 附录A application.properties配置项
  17. eclipse设置
  18. EasyUI 在Tab页用button打开新Tab
  19. MySQL 安装与使用(二)
  20. HttpWebRequest抓取网页内容与直接输入URL得到的内容不一致!球大神帮忙!!

热门文章

  1. Rabbitmq--topic
  2. 「Django」rest_framework学习系列-序列化
  3. notepad++ 正则学习记录
  4. 前端PHP入门-033-连接数据库-天龙八步
  5. [DeeplearningAI笔记]序列模型1.1-1.2序列模型及其数学符号定义
  6. CF839 B 贪心
  7. 重构改善既有代码设计--重构手法13:Inline Class (将类内联化)
  8. css单位em、px、rem和pt的区别
  9. 【BZOJ】2049: [Sdoi2008]Cave 洞穴勘测 LCT
  10. 【VIJOS】P1512 SuperBrother打鼹鼠