比赛 Asm.Def战记之圣地亚哥“杯2015 评测结果 RRRRRRRRRR
题目名称 Asm.Def的枪榴弹 最终得分 0
用户昵称 Binary10 运行时间 0.000 s
代码语言 C++ 内存使用 0.31 MiB
提交时间 2015-10-31 11:58:30
显示代码纯文本
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cmath>
#include<cctype>
#include<cstdio>
#include<string>
#include<vector>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
const int maxn = 20;
int a[maxn], b[maxn], c[maxn], d[maxn], e[maxn];
int n, k0, k1, k2, p[maxn];
int main()
{
  //freopen("asm_grenade.in", "r", stdin);
  //freopen("asm_grenade.out", "w", stdout);
  cin >> n;
  for(int i = 0; i < n; i++) scanf("%d", &a[i]);
  for(int i = 0; i < n; i++) scanf("%d", &b[i]);
  for(int i = 0; i < n; i++) scanf("%d", &c[i]);
  for(int i = 0; i < n; i++) scanf("%d", &d[i]);
  for(int i = 0; i < n; i++) scanf("%d", &e[i]);
  cin >> k0 >> k1 >> k2;
  int ans = 0;
  for(int s = 0; s < (1 << n); s++){
    int n0 = 0;
    for(int i = 0; i < n; i++)
      if(s & (1 << i)) p[n0++] = i;
    do{
      int x = k0, y = k1, z = k2;
      bool ok = true;
      for(int i = 0; i < n0; i++){
        bool check = false;
        if(x >= a[p[i]] && y >= b[p[i]]){
          check = true; x -= a[p[i]]; y -= b[p[i]];
        }else
        if(x >= a[p[i]] && y < b[p[i]] && z + y >= b[p[i]]){
          check = true; x -= a[p[i]]; y = 0; z -= (b[p[i]] - y);
        }else
        if(x < a[p[i]] && y >= b[p[i]] && z + x >= a[p[i]]){
          check = true; x = 0; y -= b[p[i]]; z -= (a[p[i]] - x);
        }else
        if(x < a[p[i]] && y < b[p[i]] && x + z >= a[p[i]] && x + y + z >= a[p[i]] + b[p[i]]){
          check = true; x = 0; y = 0; z -= (a[p[i]] + b[p[i]] - x - y);
        }
        if(check) { x += c[p[i]]; y += d[p[i]]; z += e[p[i]];}
        else {ok = false; break;}
      }
      if(ok && x + y + z > ans) ans = x + y + z;
    }while(next_permutation(p, p + n));
  }
  cout << ans << endl;
  return 0;
}