比赛 Asm.Def战记之圣地亚哥“杯2015 评测结果 EEEEEEEEEE
题目名称 Asm.Def的枪榴弹 最终得分 0
用户昵称 djj 运行时间 5.312 s
代码语言 C++ 内存使用 14.41 MiB
提交时间 2019-10-23 18:07:14
显示代码纯文本
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>

using namespace std;

inline int read() {
    char c = getchar(); int x = 0, f = 1;
    for (; c > '9' || c < '0'; c = getchar()) if (c == '-') f = -1;
    for (; c >='0' && c <='9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
    return x * f;
}

struct Point {
    int a_, b_, c_;
} now;

struct Room {
    int a_, b_, c_;
    int a, b;
} a[20];

vector <Point> h[1 << 15];
int n, a_, b_, c_, ans;
vector <int> st[20];

void djj_lxy () {
    n = read();
    for (register int i = 1; i <= n; i ++)
        a[i].a = read();
    for (register int i = 1; i <= n; i ++)
        a[i].b = read();
    for (register int i = 1; i <= n; i ++)
        a[i].a_ = read();
    for (register int i = 1; i <= n; i ++)
        a[i].b_ = read();
    for (register int i = 1; i <= n; i ++)
        a[i].c_ = read();
    a_ = read(), b_ = read(), c_ = read();
    for (register int i = 1; i <= n; i ++) {
        for (register int ia = 0; ia <= min (a[i].a, a_); ia ++)
            for (register int ib = 0; ib <= min (a[i].b, b_); ib ++)
                if (a[i].a + a[i].b - ia - ib <= c_) {
                    now.a_ = a_ - ia + a[i].a_, now.b_ = b_ - ib + a[i].b_;
                    now.c_ = c_ - (a[i].a - ia + a[i].b - ib) + a[i].c_;
                    h[1 << i].push_back (now);
                }
        st[1].push_back (1 << i);
    }
    for (register int i_ = 1; i_ <= n; i_ ++)
        for (register int j_ = 0; j_ <= st[i_].size(); j_ ++) {
            int now_ = st[i_][j_];
            for (register int i = 1; i <= n; i ++) {
                if (!(now_ & (1 << i))) {
                    for (register int j = 0; j < h[now_].size (); j ++) {
                        a_ = h[now_][j].a_, b_ = h[now_][j].b_, c_ = h[now_][j].c_;
                        for (register int ia = 0; ia <= min (a_, a[i].a); ia ++)
                            for (register int ib = 0; ib <= min (b_, a[i].b); ib ++)
                                if (a[i].a - a_ + a[i].b - b_ <= c_) {
                                    now.a_ = a_ - ia + a[i].a_, now.b_ = b_ - ib + a[i].b_;
                                    now.c_ = c_ - (a[i].a - ia + a[i].b - ib) + a[i].c_;
                                    h[now_ | (1 << i)].push_back (now);
                                }
                    }
                    bool is = 0;
                    for (register int i__ = 0; i__ < st[i_ + 1].size (); i__ ++)
                        if (st[i_ + 1][i__] == (now_ | (1 << i))) {
                            is = 1;
                            break ;
                        }
                    if (is) continue ;
                    st[i_ + 1].push_back (now_ | (1 << i));
                }
            }
        }
    for (register int i = 1; i <= (1 << (n + 1)) - 1; i ++)
        for (register int j = 0; j < h[i].size(); j ++)
            ans = max (ans, h[i][j].a_ + h[i][j].b_ + h[i][j].c_);
    printf ("%d\n", ans);
}

int main () {
    freopen ("asm_grenade.in", "r", stdin);
    freopen ("asm_grenade.out", "w", stdout);
    djj_lxy ();
}

/*
3
1 2 3
0 4 9
0 0 10
0 8 9
1 0 8
3 1 2

8
*/