#P16239. [蓝桥杯 2026 省 B] 足球训练

    ID: 18273 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度普及+/提高− 上传者: 标签>贪心二分2026蓝桥杯省赛

[蓝桥杯 2026 省 B] 足球训练

Problem Description

Xiaolan is the captain of a football team, and he is preparing for the next important match. Over the next mm days, each day he can choose one player to train, and once chosen, the training target for that day cannot be changed.

There are nn players in the team. For player ii, we know:

  • The initial strength value is aia_i.
  • The talent value is bib_i.

The training rules are as follows:

  • If Xiaolan trains player ii on some day, then on that day the player’s strength value increases by bib_i.
  • If player ii is trained for a total of kk days, then the player’s final strength value becomes: ai+kbia_i + k b_i.

The overall strength of the team is defined as the product of all players’ final strength values, i.e.:

∏i=1n(ai+kibi)\prod_{i=1}^{n} (a_i + k_i b_i)

where kik_i is the number of training days assigned to player ii, and it satisfies:

ki≥0,∑i=1nki=mk_i \ge 0, \quad \sum_{i=1}^{n} k_i = m

Xiaolan hopes to maximize the team’s overall strength by allocating these mm training days reasonably. Since the result may be very large, you only need to output the maximum value modulo 998244353998244353.

Input Format

The input has n+1n+1 lines.

The first line contains two positive integers n,mn, m, representing the number of players and the total number of days available for training.

The next nn lines each contain two positive integers ai,bia_i, b_i, representing the initial strength value and the talent value of player ii.

Output Format

Output one line containing one non-negative integer, representing the maximum possible team strength after mm days of training, modulo 998244353998244353.

2 3
4 2
5 3
66

Hint

Sample Explanation

One optimal plan is:

  • Train player 11 for 11 day.
  • Train player 22 for 22 days.

Then:

  • Player 11’s final strength is 4+2×1=64 + 2 \times 1 = 6.
  • Player 22’s final strength is 5+3×2=115 + 3 \times 2 = 11.

The team’s overall strength is 6×11=666 \times 11 = 66, so the output is 6666.

Constraints

For 30%30\% of the testdata, n,m≤8n, m \le 8.

For 60%60\% of the testdata, n,m,ai,bi≤3000n, m, a_i, b_i \le 3000.

For 100%100\% of the testdata, 1≤n≤1000001 \le n \le 100000, 1≤m≤1091 \le m \le 10^9, 1≤ai,bi≤1051 \le a_i, b_i \le 10^5.

Translated by ChatGPT 5