Cakes

시간 제한2초메모리 제한1024 MB

요약
케이크별 가격과 재료비, 필요한 도구 목록이 주어질 때, 도구 가격은 한 번만 지불한다고 보고 이익이 최대가 되도록 만들 케이크의 부분집합을 고른다.
난이도

보통10점 중 5점

유형
비트 연산, 완전 탐색, 그리디
정답자
아직 제출이 없습니다

문제

Your local cake shop is making a business plan for the next few months. The bakers have CC different recipes, each requiring their own set of ingredients and tools. During the baking, the ingredients are consumed, but the tools are not and can be reused for other recipes. Currently, the bakery has no ingredients or tools – they were all destroyed in the recent floods or taken away by the tax bureau.

The son of the main chef managed to convince everyone to only bake each type of cake once. Individuals on the internet are supposedly happy to pay extra to be the only owners of their own unique Nutty-Fudge Tart (NFT). In fact, the son has already gone ahead and estimated how much money they can earn for each type of cake. Now bakers are looking at each other, trying to figure out which types of cake to prepare for maximum profit. You are given the costs of all ingredients, tools, and prices of cakes. Your task is to determine how much profit the bakers can make.

입력

The first line contains three integers: GG, CC, and TT, the number of ingredients, the number of recipes, and the number of different tools in them, respectively. The second line contains CC space-separated integers c_1,…,c_Cc\_1, \ldots, c\_C, the prices of each cake. The third line contains GG space-separated integers g_1,…,g_Gg\_1, \ldots, g\_G, representing the prices of each ingredient. The fourth line contains TT space-separated integers t_1,…,t_Tt\_1, \ldots, t\_T, representing the prices of all tools.

This is followed by CC lines, each containing GG space-separated integers a_i,ja\_{i,j}, corresponding to the amount of ingredient jj in cake ii.

Finally, this is followed by CC lines of the following format: the ii-th row starts with an integer n_in\_i, the number of tools required for ii-th cake. This is followed by n_in\_i space-separated integers b_i,kb\_{i,k}, indicating that we need tool b_i,kb\_{i,k} to prepare cake ii (listed tools are distinct).

출력

Print a single number: the maximum profit that the cake shop can make.

제한

  • 1≤G,C,T≤2001 \leq G,C,T \leq 200
  • 0≤c_i,t_i≤1090 \leq c\_i, t\_i \leq 10^9
  • 0≤g_j,a_i,j≤1080 \leq g\_j, a\_{i,j} \leq 10^8
  • 0≤n_i≤T0 \leq n\_i \leq T
  • 1≤b_i,k≤T1 \leq b\_{i,k} \leq T

힌트

The maximum profit is made by baking cakes 1 and 2, but not cake 3.

예제1

  1. 예제 1

    입력
    5 3 4
    14 18 21
    1 2 3 1 2
    5 6 3 10
    0 0 1 2 0
    1 2 0 1 2
    5 2 1 0 0
    2 1 2
    2 2 3
    2 3 4
    
    예상 출력
    3