#P1417. 烹调方案

烹调方案

Description

There are nn ingredients. Each ingredient has three attributes, aia_i, bib_i, and cic_i. If ingredient ii is completed at time tt, you gain a deliciousness score of ait×bia_i-t\times b_i. Cooking ingredient ii takes cic_i time.

As everyone knows, gw is not very good at cooking, so you need to design a cooking plan to maximize the deliciousness score. All cooking must be finished within time TT.

Input Format

The first line contains two positive integers TT and nn, representing the time needed to reach Earth and the number of ingredients.

  • The next line contains nn integers, aia_i.
  • The next line contains nn integers, bib_i.
  • The next line contains nn integers, cic_i.

Output Format

Output the maximum deliciousness score.

74 1
502
2
47

408

Hint

  • Constraints:
    • For 40%40\% of the testdata, 1n101 \le n \le 10.
    • For 100%100\% of the testdata, 1n501 \le n \le 50.
    • All numbers are less than 10510^5.
  • Source: adapted by tinylic.

Translated by ChatGPT 5