#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>

#define __clock__
#define __precision__ 10
#define iostream_untie true
#define debug_stream std::cerr


namespace std
{
    // hash
    template <class T> size_t hash_combine(size_t seed, T const &key) { return seed ^ (hash<T>()(key) + 0x9e3779b9 + (seed << 6) + (seed >> 2)); }
    template <class T, class U> struct hash<pair<T, U>> { size_t operator()(pair<T, U> const &pr) const { return hash_combine(hash_combine(0, pr.first), pr.second); } };
    template <class tuple_t, size_t index = tuple_size<tuple_t>::value - 1> struct tuple_hash_calc { static size_t apply(size_t seed, tuple_t const &t) { return hash_combine(tuple_hash_calc<tuple_t, index - 1>::apply(seed, t), get<index>(t)); } };
    template <class tuple_t> struct tuple_hash_calc<tuple_t, 0> { static size_t apply(size_t seed, tuple_t const &t) { return hash_combine(seed, get<0>(t)); } };
    template <class... T> struct hash<tuple<T...>> { size_t operator()(tuple<T...> const &t) const { return tuple_hash_calc<tuple<T...>>::apply(0, t); } };
    // iostream
    template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.first >> p.second; }
    template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.first << ' ' << p.second; }
    template <class tuple_t, size_t index> struct tupleos { static ostream &apply(ostream &os, const tuple_t &t) { tupleos<tuple_t, index - 1>::apply(os, t); return os << ' ' << get<index>(t); } };
    template <class tuple_t> struct tupleos<tuple_t, 0> { static ostream &apply(ostream &os, const tuple_t &t) { return os << get<0>(t); } };
    template <class... T> ostream &operator<<(ostream &os, const tuple<T...> &t)  { return tupleos<tuple<T...>, tuple_size<tuple<T...>>::value - 1>::apply(os, t); }
    template <> ostream &operator<<(ostream &os, const tuple<> &t) { return os; }
    template <class Container, typename Value = typename Container::value_type, enable_if_t<!is_same<decay_t<Container>, string>::value, nullptr_t> = nullptr>
    istream& operator>>(istream& is, Container &cont) { for(auto&& e : cont) is >> e; return is; }
    template <class Container, typename Value = typename Container::value_type, enable_if_t<!is_same<decay_t<Container>, string>::value, nullptr_t> = nullptr>
    ostream& operator<<(ostream& os, const Container &cont) { bool flag = 1; for(auto&& e : cont) flag ? flag = 0 : (os << ' ', 0), os << e; return os; }
} // namespace std

namespace execution
{
    using namespace std::chrono;
    system_clock::time_point start_time, end_time;
    long long get_elapsed_time() { end_time = system_clock::now(); return duration_cast<milliseconds>(end_time - start_time).count(); }
    void print_elapsed_time() { std::cerr << "\n----- Exec time : " << get_elapsed_time() << " ms -----\n"; }
    struct setupper
    {
        setupper()
        {
            if(iostream_untie) std::ios::sync_with_stdio(false), std::cin.tie(nullptr);
            std::cout << std::fixed << std::setprecision(__precision__);
    #ifdef stderr_path
            if(freopen(stderr_path, "a", stderr))
            {
                std::cerr << std::fixed << std::setprecision(__precision__);
            }
    #endif
    #ifdef stdout_path
            if(not freopen(stdout_path, "w", stdout))
            {
                freopen("CON", "w", stdout);
                std::cerr << "Failed to open the stdout file\n\n";
            }
            std::cout << "";
    #endif
    #ifdef stdin_path
            if(not freopen(stdin_path, "r", stdin))
            {
                freopen("CON", "r", stdin);
                std::cerr << "Failed to open the stdin file\n\n";
            }
    #endif
    #ifdef LOCAL
            std::cerr << "----- stderr at LOCAL -----\n\n";
            atexit(print_elapsed_time);
    #else
            fclose(stderr);
    #endif
    #ifdef __clock__
            start_time = system_clock::now();
    #endif
        }
    } __setupper;
    class myclock_t
    {
        system_clock::time_point built_pt, last_pt; int built_ln, last_ln;
        std::string built_func, last_func; bool is_built = false;
      public:
        void build(int crt_ln, const std::string &crt_func)
        {
            is_built = true, last_pt = built_pt = system_clock::now(),  last_ln = built_ln = crt_ln, last_func = built_func = crt_func;
        }
        void set(int crt_ln, const std::string &crt_func)
        {
            if(is_built) last_pt = system_clock::now(), last_ln = crt_ln, last_func = crt_func;
            else debug_stream << "[ " << crt_ln << " : " << crt_func << " ] " << "myclock_t::set failed (yet to be built!)\n";
        }
        void get(int crt_ln, const std::string &crt_func)
        {
            if(is_built)
            {
                system_clock::time_point crt_pt(system_clock::now());
                long long diff = duration_cast<milliseconds>(crt_pt - last_pt).count();
                debug_stream << diff << " ms elapsed from" << " [ " << last_ln << " : " << last_func << " ]";
                if(last_ln == built_ln) debug_stream << " (when built)";
                debug_stream << " to" << " [ " << crt_ln << " : " << crt_func << " ]" << "\n";
                last_pt = built_pt, last_ln = built_ln, last_func = built_func;
            }
            else
            {
                debug_stream << "[ " << crt_ln << " : " << crt_func << " ] " << "myclock_t::get failed (yet to be built!)\n";
            }
        }
    };
} // namespace execution

#ifdef __clock__
    execution::myclock_t __myclock;
    #define build_clock() __myclock.build(__LINE__, __func__)
    #define set_clock() __myclock.set(__LINE__, __func__)
    #define get_clock() __myclock.get(__LINE__, __func__)
#else
    #define build_clock() ((void)0)
    #define set_clock() ((void)0)
    #define get_clock() ((void)0)
#endif

template <class cap_t, class cost_t>
struct Flow
{
    Flow(size_t _V) : V(_V), adj(_V) {}
    void add_edge(size_t from, size_t to, cap_t cap, cost_t cost = cost_t(0))
    {
        if(cap <= 0) return;
        adj[from].emplace_back(from, to, cap, cost, adj[to].size());
        adj[to].emplace_back(to, from, 0, -cost, adj[from].size() - 1);
    }
  protected:
    struct edge
    {
        size_t from, to; cap_t cap; cost_t cost; size_t rev;
        edge(size_t _from, size_t _to, cap_t _cap, cost_t _cost, size_t _rev) : from(_from), to(_to), cap(_cap), cost(_cost), rev(_rev) {}
    }; // struct edge
    size_t V;
    std::vector<std::vector<edge>> adj;
}; // struct Flow

template <class cap_t, class cost_t>
class Primal_Dual : public Flow<cap_t, cost_t>
{
    using edge = typename Flow<cap_t, cap_t>::edge;
    using Flow<cap_t, cap_t>::V; using Flow<cap_t, cap_t>::adj;
    bool neg_cost;
    std::vector<cost_t> dist, h;
    std::vector<size_t> prev_v;
    std::vector<edge*> prev_e;
    bool dijkstra(size_t s, size_t t)
    {
        using info = std::pair<cost_t, size_t>;
        std::priority_queue<info, std::vector<info>, std::greater<info>> que;
        fill(dist.begin(), dist.end(), inf_cost);
        que.emplace(dist[s] = 0, s);
        while(!que.empty())
        {
            cost_t _cost; size_t v;
            std::tie(_cost, v) = que.top(), que.pop();
            if(_cost != dist[v]) continue;
            for(auto &&e : adj[v])
            {
                if(e.cap > 0 && dist[v] + h[v] + e.cost < dist[e.to] + h[e.to])
                {
                    que.emplace(dist[e.to] = dist[v] + h[v] - h[e.to] + e.cost, e.to);
                    prev_v[e.to] = v;
                    prev_e[e.to] = &e;
                }
            }
        }
        if(dist[t] >= inf_cost) return false;
        for(size_t v = 0; v != V; ++v)
        {
            h[v] += dist[v];
            if(h[v] > inf_cost) h[v] = inf_cost;
        }
        return true;
    }
    bool bellman_ford(size_t s, size_t t)
    {
        fill(dist.begin(), dist.end(), inf_cost);
        dist[s] = 0;
        for(size_t t = V - 1; t; --t)
        {
            bool update = false;
            for(size_t v = 0; v != V; ++v)
            {
                for(auto &&e : adj[v])
                {
                    if(e.cap > 0 && dist[v] + h[v] + e.cost < dist[e.to] + h[e.to])
                    {
                        dist[e.to] = dist[v] + h[v] + e.cost - h[e.to];
                        prev_v[e.to] = v;
                        prev_e[e.to] = &e;
                        update = true;
                    }
                }
            }
            if(!update) break;
        }
        if(dist[t] >= inf_cost) return false;
        for(size_t v = 0; v != V; ++v)
        {
            h[v] += dist[v];
            if(h[v] > inf_cost) h[v] = inf_cost;
        }
        return true;
    }
  public:
    const cost_t inf_cost = std::numeric_limits<cost_t>::max() / 4;
    Primal_Dual(size_t V) : Flow<cap_t, cost_t>(V), neg_cost() {}
    void add_edge(size_t s, size_t t, cap_t cap, cost_t cost)
    {
        if(cap <= 0) return;
        // if(cost < 0) neg_cost = true;
        Flow<cap_t, cost_t>::add_edge(s, t, cap, cost);
    }
    cost_t min_cost_flow(size_t s, size_t t, cap_t f)
    {
        cost_t res = 0;

        if(neg_cost)
        {
            set_clock();
            neg_cost = false;
            {
                const size_t _s = V++, _t = V++;
                adj.resize(V);
                add_edge(_s, s, f, 0);
                add_edge(t, _t, f, 0);
                s = _s, t = _t;
            }
            std::vector<cap_t> scap(V), tcap(V);
            for(size_t v = 0; v != V; ++v)
            {
                cap_t cap_sum = 0;
                for(auto &&e : adj[v])
                {
                    if(e.cap > 0 and e.cost < 0)
                    {
                        scap[e.to] += e.cap;
                        tcap[v] += e.cap;
                        res += e.cap * e.cost;
                        f += e.cap;
                        adj[e.to][e.rev].cap += e.cap;
                        cap_sum += e.cap;
                        e.cap = 0;
                    }
                }
            }
            for(size_t v = 0; v != V; ++v)
            {
                add_edge(s, v, scap[v], 0);
                add_edge(v, t, tcap[v], 0);
            }
            get_clock();
        }

        dist.resize(V), h.assign(V, 0);
        prev_v.resize(V), prev_e.resize(V);
        set_clock();
        while(f > 0)
        {
            // if(!dijkstra(s, t)) return inf_cost;
            if(!bellman_ford(s, t)) return inf_cost;
            cap_t d = f;
            for(int v = t; v != s; v = prev_v[v]) d = std::min(d, prev_e[v]->cap);
            f -= d, res += h[t] * d;
            for(int v = t; v != s; v = prev_v[v])
            {
                prev_e[v]->cap -= d;
                adj[v][prev_e[v]->rev].cap += d;
            }
        }
        get_clock();
        return res;
    }
}; // class Primal_Dual

signed main()
{
    using namespace std;
    ios::sync_with_stdio(false);
    cin.tie(0);
    build_clock();

    int n,m,k; cin>>n>>m>>k;
    Primal_Dual<int,int> flow(2+n+m);
    vector<int> a(n); cin>>a;
    const int s=n+m,t=s+1;
    for(int i=0; i<m; ++i)
    {
        for(int j=0; j<n; ++j)
        {
            int b; cin>>b;
            flow.add_edge(i,j+m,1,-b);
        }
    }
    for(int i=m; i<m+n; ++i)
    {
        flow.add_edge(i,t,1,a[i-m]);
    }
    for(int i=0; i<m; ++i)
    {
        int t; cin>>t;
        flow.add_edge(s,i,t,0);
    }
    flow.add_edge(s,t,n,0);

    cout << accumulate(a.begin(),a.end(),0)-flow.min_cost_flow(s,t,n-k) << "\n";
}



Measured memory_bytes: 3744