#P2623. 物品选取

物品选取

Description

Xiao X can choose from nn items, divided into three categories: A, B, and C.

  1. Type A items have values that change with the volume you allocate to them. Their value follows the function v(x)=Ax2Bxv(x) = A x^2 - B x, where AA and BB are two parameters for each type A item. Note: for type A items, there is only one item for each volume amount.

  2. Type B items have fixed value AA and volume BB, and each has a parameter CC, which is the number of copies available.

  3. Type C items also have fixed value AA and volume BB, but the number of copies available is unlimited.

Your task is to determine the maximum total value Xiao X can carry in his backpack.

Input Format

The first line contains two integers nn and mm, the number of items and the backpack capacity.

Then follow nn lines, each describing one item. The first integer xx indicates the item category:

  • If x=1x = 1, it is a type A item. The next two integers AA, BB are this item's two parameters.
  • If x=2x = 2, it is a type B item. The next three integers AA, BB, CC denote the item's value, its volume, and the number of copies available, respectively.
  • If x=3x = 3, it is a type C item. The next two integers AA, BB denote the item's value and its volume.

Output Format

Output a single line containing one integer: the maximum total value that can be carried in the backpack.

1 0
1 1 1
0
4 10
2 1 2 1
1 1 2
3 5 2
2 200 2 3
610

Hint

  • For 50%50\% of the testdata, only types B and C appear.
  • For 70%70\% of the testdata, 1n1001 \le n \le 100, 1m5001 \le m \le 500, 0A,B,C2000 \le A, B, C \le 200.
  • For 100%100\% of the testdata, 1n1001 \le n \le 100, 1m20001 \le m \le 2000, 0A,B,C2000 \le A, B, C \le 200.

Translated by ChatGPT 5