QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 2048 MB Total points: 100

#10535. Bottles

統計

在著名的 ICPC 比赛中,将有 $n$ 名选手参赛。赛道全长 $m$ 公里,为了安全起见,赛道被划分为 $m$ 个区间。每个区间长度为 1 公里,第 $i$ 个区间 ($1 \le i \le m$) 为区间 $(i - 1, i)$,即距离起点 $i - 1$ 公里到 $i$ 公里之间的路段。我们忽略选手距离起点恰好为整数的情况。由于天气炎热,组织者希望放置足够的水瓶。他们会在每个区间内放置一定数量的水瓶。当一名选手拿走一瓶水时,他们会立即补充一瓶。他们发现,通过计算比赛期间该区间内同时存在的选手最大数量,可以得到最优的水瓶数量。根据每位选手的过往记录,他们已经估算出了每位选手在每个区间内花费的时间(秒)。

考虑以下示例。共有三名选手,赛道长度为 6 公里。下表显示了选手在每个区间内花费的时间(单位:秒)。

选手 区间 1 区间 2 区间 3 区间 4 区间 5 区间 6
1 350s 360s 370s 380s 390s 400s
2 240s 240s 240s 240s 240s 240s
3 480s 480s 520s 600s 600s 600s

现在我们来检查比赛期间每个区间内的选手人数。下表并不完整。当你填满整个表格并计算每个区间的最大选手人数时,你会发现区间 1 需要放置 3 瓶水,区间 2 和区间 3 需要 2 瓶,区间 4、区间 5 和区间 6 需要 1 瓶。注意,在 480 秒时,选手 2 离开区间 2,选手 3 进入区间 2,由于他们距离起点的距离为整数,这两种情况均被忽略。在 480 秒时,区间 1 和区间 3 中没有选手,选手 1 在区间 2 中。例如,在 481 秒时,选手 1 和选手 3 将同时在区间 2 中。

经过时间 区间 1 区间 2 区间 3 区间 4 区间 5 区间 6
(0s, 240s) 3 0 0 0 0 0
(240s, 350s) 2 1 0 0 0 0
(350s, 480s) 1 2 0 0 0 0
(480s, 710s) 0 2 1 0 0 0
(710s, 720s) 0 1 2 0 0 0
... ... ... ... ... ... ...

给定选手人数、赛道长度以及每位选手在每个区间内花费的时间,编写一个程序来计算每个区间需要放置的水瓶数量。

输入格式

程序从标准输入读取数据。输入的第一行包含两个整数 $n$ 和 $m$ ($1 \le n \le 100$, $1 \le m \le 300$),其中 $n$ 是选手人数,$m$ 是赛道长度。接下来的 $n$ 行中,第 $i$ 行包含 $m$ 个正整数,表示选手 $i$ 在每个区间内花费的时间。更准确地说,该行中的第 $j$ 个数字是选手 $i$ 在区间 $j$ 中花费的时间。没有任何选手在任何区间内花费的时间超过 10,000 秒。

输出格式

程序将结果写入标准输出。仅打印一行。该行应包含从区间 1 到区间 $m$ 每个区间所需的水瓶数量。

样例

样例输入 1

3 6
350 360 370 380 390 400
240 240 240 240 240 240
480 480 520 600 600 600

样例输出 1

3 2 2 1 1 1

样例输入 2

4 5
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 1 1

样例输出 2

4 4 4 4 4

样例输入 3

3 5
1 1 1 1 1
5 5 5 5 5
25 25 25 25 25

样例输出 3

3 1 1 1 1

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.