#P5322. [BJOI2019] 排兵布阵

    ID: 6056 远端评测题 1000ms 500MiB 尝试: 2 已通过: 2 难度: 6 上传者: 标签>动态规划 DP2019各省省选北京O2优化背包 DP

[BJOI2019] 排兵布阵

Problem Description

Xiao C is playing a troop deployment game. In the game, there are nn castles, and each match is a battle between two players competing for these castles. Each player has mm soldiers, and may send aia_i soldiers to the ii-th castle to compete for it, as long as the total number of soldiers sent does not exceed mm.

If the number of soldiers a player sends to the ii-th castle is strictly greater than twice the number sent by the opponent, then the player occupies this castle and gains ii points.

Now Xiao C is going to play head-to-head matches against another ss players. The troop deployment plan used in these ss matches must be the same. Through some means, Xiao C has learned the strategies that the other ss players are going to use, and he wants to know what strategy he should use to maximize his total score.

Since the answer may not be unique, you only need to output the maximum possible total score of Xiao C.

Input Format

The first line contains three positive integers s,n,ms,n,m, representing the number of players other than Xiao C, the number of castles, and the number of soldiers each player has.

The next ss lines each contain nn non-negative integers, describing one player’s strategy. The ii-th number aia_i means the number of soldiers this player sends to the ii-th castle.

Output Format

Output one line with one non-negative integer, representing the maximum score Xiao C can obtain.

1 3 10
2 2 6
3
2 3 10
2 2 6
0 0 0
8

Hint

Explanation for Sample 1:
Xiao C’s best strategy is to send 55 soldiers to the 11-st castle and 55 soldiers to the 22-nd castle.

Explanation for Sample 2:
One of Xiao C’s best strategies is to send 22 soldiers to the 11-st castle, 55 soldiers to the 22-nd castle, and 11 soldier to the 33-rd castle.

Constraints:
For 10%10\% of the testdata: s=1,n3,m10s=1,n \le 3,m \le 10.
For 20%20\% of the testdata: s=1,n10,m100s=1,n \le 10,m \le 100.
For 40%40\% of the testdata: n10,m100n \le 10,m \le 100.
For another 20%20\% of the testdata: s=1s=1.
For 100%100\% of the testdata:
1s1001 \le s \le 100.
1n1001 \le n \le 100.
1m200001 \le m \le 20000.
For each player, ai0a_i \ge 0, and i=1naim\sum\limits_{i=1}^n a_i \le m.

Translated by ChatGPT 5