Task Assignment to Two Employees

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

요약
n개의 과제를 두 직원에게 각각 순서를 정해 나누어 맡기고, 과제를 마칠 때마다 숙련도가 s만큼 오르는 상황에서 총이익 p*v의 합을 최대로 만든다.
난이도

어려움10점 중 8점

유형
동적 계획법, 정렬, 그리디, 조합론
정답자
아직 제출이 없습니다

문제

Hanako is the CEO of a small company with two employees. She currently has some number of tasks and aims to earn some profits by making the employees do the tasks. Employees can enhance their skills through the tasks and, with higher skills, a larger profit can be earned from the same task. Thus, assigning tasks to appropriate employees in an appropriate order is important for maximizing the total profit.

For each pair (i,j)(i, j) of employee ii and task jj, two non-negative integers v_i,jv\_{i,j} and s_i,js\_{i,j} are defined. Here, v_i,jv\_{i,j} is the task compatibility and s_i,js\_{i,j} is the amount of skill growth. When task jj has been completed by employee ii whose skill point was pp, a profit of p×v_i,jp \times v\_{i,j} is earned, and his skill point increases to p+s_i,jp + s\_{i,j}. Initially, both employees have skill points of p_0p\_0.

Note that the skill points are individual, and completing a task by one employee does not change the skill point of the other. Each task must be done only once by only one employee. The order of tasks to carry out can be arbitrarily chosen.

입력

The input consists of a single test case of the following format.

nn p_0p\_0

s_1,1s\_{1,1} ⋯\cdots s_1,ns\_{1,n}

s_2,1s\_{2,1} ⋯\cdots s_2,ns\_{2,n}

v_1,1v\_{1,1} ⋯\cdots v_1,nv\_{1,n}

v_2,1v\_{2,1} ⋯\cdots v_2,nv\_{2,n}

All the input items are non-negative integers. The number of tasks nn satisfies 1≤n≤1001 ≤ n ≤ 100. The initial skill point p_0p\_0 satisfies 0≤p_0≤1080 ≤ p\_0 ≤ 10^8. Each s_i,js\_{i,j} is the amount of skill growth for the employee ii by completing the task jj, which satisfies 0≤s_i,j≤1060 ≤ s\_{i,j} ≤ 10^6. Each v_i,jv\_{i,j} is the task compatibility of the employee ii with the task jj, which satisfies 0≤v_i,j≤1060 ≤ v\_{i,j} ≤ 10^6.

출력

Output the maximum possible total profit in one line.

예제2

  1. 예제 1

    입력
    4 0
    10000 1 1 1
    1 1 10000 1
    1 10000 1 1
    1 1 1 10000
    
    예상 출력
    200000000
    
  2. 예제 2

    입력
    3 1
    1 1 1
    2 2 2
    2 2 2
    1 1 1
    
    예상 출력
    12