QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 512 MB مجموع النقاط: 10

#2114. T恤 [C]

الإحصائيات

准备好争夺 2021 年 Potyczki Algorytmiczne 的 T 恤了吗?通常,我们会将 T 恤颁发给 B+C 组排名第 1 到第 256 名的参赛者。在排名中,我们主要比较参赛者在 B 组和 C 组题目中获得的总分;如果总分相同,我们还会考虑各题得分的详细分布情况。

有时,我们能够破例颁发超过 256 件 T 恤,因为我们希望满足一个附加条件:如果参赛者 A 的得分至少与参赛者 B 一样多,且参赛者 B 获得了 T 恤,那么参赛者 A 也必须获得 T 恤,无论其具体得分分布如何。

在实践中,并不总是能够满足上述附加条件,因为这可能意味着我们需要颁发的 T 恤数量远超预期。这也是我们鼓励参赛者尽可能多地获取分数的原因之一,即使是提交时间复杂度非最优的解法(即使题目中没有明确说明,这些解法通常也能获得部分分数)。这有助于平滑排名并让所有相关方(尤其是组织者)感到满意。

如果有 $n$ 名参赛者参加比赛,组织者希望至少颁发 $k$ 件 T 恤,且参赛者依次获得了 $a_1, a_2, a_3, \dots, a_n$ 分,那么为了同时满足附加条件,组织者至少需要颁发多少件 T 恤?

输入格式

第一行包含两个整数 $n$ 和 $k$ ($1 \le k \le n \le 2000$),分别表示参赛者人数和组织者希望颁发的最小 T 恤数量。

第二行包含 $n$ 个整数 $a_1, a_2, a_3, \dots, a_n$ ($1 \le a_i \le 120$),其中 $a_i$ 表示第 $i$ 位参赛者获得的得分。

输出格式

输出一个整数,表示为了满足附加条件,组织者必须颁发的最小 T 恤数量。

样例

输入 1

5 3
75 90 120 75 40

输出 1

4

说明 1

组织者不能只颁发 3 件 T 恤(例如颁发给第 2、3、4 名参赛者),因为这样第一位参赛者会感到不公(他的得分不低于第四位参赛者,但却没有获得 T 恤,因此不满足附加条件)。解决方案是给除最后一名以外的所有参赛者都颁发 T 恤。

子任务

在某些测试组中,满足条件 $k = 1$,即组织者希望至少颁发一件 T 恤。

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.