#abc323c. C - World Tour Finals

C - World Tour Finals

Score : 250250 points

问题描述

正在进行一场编程比赛——世界巡回赛总决赛,有 NN 名选手参赛,目前比赛时间已经过半。本场竞赛共有 MM 道题目,第 ii 题的分数 AiA_i 是在 50050025002500(包含)之间、能被 100100 整除的数。

对于每个 i=1,,Ni = 1, \ldots, N,我们给出一个字符串 SiS_i,表示选手 ii 已经解决的题目。SiS_i 是长度为 MM 的由 ox 组成的字符串,其中 SiS_i 的第 jj 个字符如果是 o,表示选手 ii 已经解决第 jj 题;如果是 x,则表示他们还未解决这道题。注意,在当前情况下,没有选手已经解决了所有的问题。

选手 ii 的总得分计算为其已解决题目得分之和,再加上 奖励分数 ii 分。

对于每个 i=1,,Ni = 1, \ldots, N,请回答以下问题:

  • 至少需要选手 ii 解决多少道尚未解决的问题才能使其总分超过其他所有选手当前的总分?

请注意,在本题描述的条件及限制下,可以证明选手 ii 通过解决所有剩余问题一定能超过其他所有选手当前的总分,因此答案总是存在的。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

The programming contest World Tour Finals is underway, where NN players are participating, and half of the competition time has passed. There are MM problems in this contest, and the score AiA_i of problem ii is a multiple of 100100 between 500500 and 25002500, inclusive.

For each i=1,,Ni = 1, \ldots, N, you are given a string SiS_i that indicates which problems player ii has already solved. SiS_i is a string of length MM consisting of o and x, where the jj-th character of SiS_i is o if player ii has already solved problem jj, and x if they have not yet solved it. Here, none of the players have solved all the problems yet.

The total score of player ii is calculated as the sum of the scores of the problems they have solved, plus a bonus score of ii points.
For each i=1,,Ni = 1, \ldots, N, answer the following question.

  • At least how many of the problems that player ii has not yet solved must player ii solve to exceed all other players' current total scores?

Note that under the conditions in this statement and the constraints, it can be proved that player ii can exceed all other players' current total scores by solving all the problems, so the answer is always defined.

Constraints

  • 2N1002\leq N\leq 100
  • 1M1001\leq M\leq 100
  • 500Ai2500500\leq A_i\leq 2500
  • AiA_i is a multiple of 100100.
  • SiS_i is a string of length MM consisting of o and x.
  • SiS_i contains at least one x.
  • All numeric values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN MM

A1A_1 A2A_2 \ldots AMA_M

S1S_1

S2S_2

\vdots

SNS_N

Output

Print NN lines. The ii-th line should contain the answer to the question for player ii.

Sample Input 1

3 4
1000 500 700 2000
xxxo
ooxx
oxox

Sample Output 1

0
1
1

The players' total scores at the halfway point of the competition time are 20012001 points for player 11, 15021502 points for player 22, and 17031703 points for player 33.

Player 11 is already ahead of all other players' total scores without solving any more problems.

Player 22 can, for example, solve problem 44 to have a total score of 35023502 points, which would exceed all other players' total scores.

Player 33 can also, for example, solve problem 44 to have a total score of 37033703 points, which would exceed all other players' total scores.

Sample Input 2

5 5
1000 1500 2000 2000 2500
xxxxx
oxxxx
xxxxx
oxxxx
oxxxx

Sample Output 2

1
1
1
1
0

Sample Input 3

7 8
500 500 500 500 500 500 500 500
xxxxxxxx
oxxxxxxx
ooxxxxxx
oooxxxxx
ooooxxxx
oooooxxx
ooooooxx

Sample Output 3

7
6
5
4
3
2
0

update @ 2024/3/10 01:44:25