CF1776C.Library game

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Alessia and Bernardo are discovering the world of competitive programming through the books of their university library.

The library consists of mm sections numbered from 11 to mm. Each section contains only books dedicated to a particular subject and different sections correspond to different subjects. In order to prevent the students from wandering in the library, the university has established a system of passes. Each pass has a length yy associated to it and allows access to an interval of yy consecutive sections in the library. During a visit, the student must choose exactly one book from one of these sections and leave the library. Each pass can be used only once.

At the moment Alessia and Bernardo have nn passes of lengths x1, x2, …, xnx_1, \, x_2, \, \dots, \, x_n. They have different opinions on the best way to improve: Alessia thinks that it is important to study many different topics, while Bernardo believes that it is important to study deeply at least one topic. So, Alessia wants to use the nn passes to get nn books on distinct topics, while Bernardo would like to get at least two books on the same topic.

They have reached the following agreement: for each of the following nn days, Alessia will choose a pass of length yy among those which are still available and an interval of yy sections in the library, and Bernardo will go into the library and will take exactly one book from one of those sections.

Can Bernardo manage to get at least two books on the same subject, or will Alessia be able to avoid it?

You should decide whether you want to be Alessia or Bernardo, and you have to fulfill the goal of your chosen character. The judge will impersonate the other character. Note that, even if at some moment Bernardo has already taken two books on the same subject, the interaction should go on until the end of the nn days.

阿莱西娅和贝尔纳多正通过大学图书馆的书籍来探索竞技编程的世界。

图书馆共有 mm 个区域,编号从 11 到 mm。每个区域仅存放某一特定学科的书籍,且不同区域对应不同学科。为防止学生在图书馆内随意走动,大学建立了一套通行证系统。每张通行证具有一个关联长度 yy,允许进入图书馆中连续的 yy 个区域。每次访问时,学生必须恰好从这些区域中的一个区域选取一本书,然后离开图书馆。每张通行证仅能使用一次。

目前,阿莱西娅和贝尔纳多共有 nn 张通行证,其长度分别为 x1, x2, …, xnx_1, \, x_2, \, \dots, \, x_n。他们对如何高效提升能力持有不同看法:阿莱西娅认为广泛涉猎多个主题至关重要,而贝尔纳多则坚信至少深入钻研一个主题才最为重要。因此,阿莱西娅希望利用这 nn 张通行证获取 nn 本主题互不相同的书;而贝尔纳多则希望至少获得两本主题相同的书。

他们达成了如下约定:在接下来的 nn 天中,每天由阿莱西娅从尚余的通行证中选择一张长度为 yy 的通行证,并选定图书馆中一段长度为 yy 的连续区域;随后贝尔纳多进入图书馆,并恰好从该段区域内的某个区域取走一本书。

贝尔纳多能否成功获取至少两本主题相同的书?抑或阿莱西娅总能阻止这种情况发生?

你需要决定自己扮演阿莱西娅还是贝尔纳多,并完成所选角色的目标。评测机将扮演另一方角色。注意:即使在某时刻贝尔纳多已取得两本主题相同的书,交互仍需持续至 nn 天全部结束。

输入格式

The first line contains two integers nn and mm (1≤n≤1001 \le n \le 100, n≤m≤5000n \le m \le 5000) — the number of passes and the number of sections.

The second line contains nn integers x1, x2, …, xnx_1, \, x_2, \, \dots, \, x_n (1≤xi≤m1 \le x_i \le m) — the lengths of the passes available.

第一行包含两个整数 nn 和 mm(1≤n≤1001 \le n \le 100,n≤m≤5000n \le m \le 5000)—— 分别表示可用的路段长度种类数和总路段数。

第二行包含 nn 个整数 x1, x2, …, xnx_1, \, x_2, \, \dots, \, x_n(1≤xi≤m1 \le x_i \le m)—— 表示可用的各路段长度。

输入输出样例

  • 输入#1

    5 14
    3 7 2 3 10

    输出#1

    -
  • 输入#2

    4 10
    4 1 6 4

    输出#2

    -

说明/提示

In the first sample, it can be shown that Alessia can accomplish her goal. An example of interaction (after reading the input) follows:

\\begin{array}{|c|c|c|} \\hline \\textbf{Contestant} & \\textbf{Judge} & \\textbf{Explanation} \\\\ \\hline \\texttt{Alessia} & & \\text{The program will act as Alessia} \\\\ \\hline 3 \\quad 11 & & \\text{Choose $y = 3$ and $a = 11$} \\\\ \\hline & 13 & \\text{Judge selects $b = 13$} \\\\ \\hline 10 \\quad 2 & & \\text{Choose $y = 10$ and $a = 2$} \\\\ \\hline & 9 & \\text{Judge selects $b = 9$} \\\\ \\hline 7 \\quad 1 & & \\text{Choose $y = 7$ and $a = 1$} \\\\ \\hline & 4 & \\text{Judge selects $b = 4$} \\\\ \\hline 2 \\quad 10 & & \\text{Choose $y = 2$ and $a = 10$} \\\\ \\hline & 10 & \\text{Judge selects $b = 10$} \\\\ \\hline 3 \\quad 6 & & \\text{Choose $y = 3$ and $a = 6$} \\\\ \\hline & 7 & \\text{Judge selects $b = 7$} \\\\ \\hline \\end{array}

The program of the contestant wins because all the books chosen by Bernardo pertain to different topics. The actions performed by the contestant and the judge in this example of interaction may be non-optimal.

In the second sample, it can be shown that Bernardo can manage to fulfil his goal. An example of interaction (after reading the input) follows:

\\begin{array}{|c|c|c|} \\hline \\textbf{Contestant} & \\textbf{Judge} & \\textbf{Explanation} \\\\ \\hline \\texttt{Bernardo} & & \\text{The program will act as Bernardo} \\\\ \\hline & 4 \\quad 1 & \\text{Judge chooses $y = 4$ and $a = 1$} \\\\ \\hline 4 & & \\text{Select $b = 4$} \\\\ \\hline & 1 \\quad 10 & \\text{Judge chooses $y = 1$ and $a = 10$} \\\\ \\hline 10 & & \\text{Select $b = 10$} \\\\ \\hline & 6 \\quad 3 & \\text{Judge chooses $y = 6$ and $a = 3$} \\\\ \\hline 4 & & \\text{Select $b = 4$} \\\\ \\hline & 4 \\quad 5 & \\text{Judge chooses $y = 4$ and $a = 5$} \\\\ \\hline 8 & & \\text{Select $b = 8$} \\\\ \\hline \\end{array}

The program of the contestant wins because Bernardo has selected two books on topic number 44. The actions performed by the contestant and the judge in this example of interaction may be non-optimal.

在第一个样例中,可以证明阿莱西娅能够实现她的目标。以下是一个交互示例(在读入输入之后):

参赛者裁判说明Alessia程序将作为阿莱西娅运行311选择 y=3 和 a=1113裁判选择 b=13102选择 y=10 和 a=29裁判选择 b=971选择 y=7 和 a=14裁判选择 b=4210选择 y=2 和 a=1010裁判选择 b=1036选择 y=3 和 a=67裁判选择 b=7\begin{array}{|c|c|c|} \hline \textbf{参赛者} & \textbf{裁判} & \textbf{说明} \\ \hline \texttt{Alessia} & & \text{程序将作为阿莱西娅运行} \\ \hline 3 \quad 11 & & \text{选择 $y = 3$ 和 $a = 11$} \\ \hline & 13 & \text{裁判选择 $b = 13$} \\ \hline 10 \quad 2 & & \text{选择 $y = 10$ 和 $a = 2$} \\ \hline & 9 & \text{裁判选择 $b = 9$} \\ \hline 7 \quad 1 & & \text{选择 $y = 7$ 和 $a = 1$} \\ \hline & 4 & \text{裁判选择 $b = 4$} \\ \hline 2 \quad 10 & & \text{选择 $y = 2$ 和 $a = 10$} \\ \hline & 10 & \text{裁判选择 $b = 10$} \\ \hline 3 \quad 6 & & \text{选择 $y = 3$ 和 $a = 6$} \\ \hline & 7 & \text{裁判选择 $b = 7$} \\ \hline \end{array}

参赛者程序获胜,因为贝尔纳多所选的所有书籍均属于不同主题。本交互示例中参赛者与裁判所执行的操作未必是最优的。

在第二个样例中,可以证明贝尔纳多能够实现他的目标。以下是一个交互示例(在读入输入之后):

参赛者裁判说明Bernardo程序将作为贝尔纳多运行41裁判选择 y=4 和 a=14选择 b=4110裁判选择 y=1 和 a=1010选择 b=1063裁判选择 y=6 和 a=34选择 b=445裁判选择 y=4 和 a=58选择 b=8\begin{array}{|c|c|c|} \hline \textbf{参赛者} & \textbf{裁判} & \textbf{说明} \\ \hline \texttt{Bernardo} & & \text{程序将作为贝尔纳多运行} \\ \hline & 4 \quad 1 & \text{裁判选择 $y = 4$ 和 $a = 1$} \\ \hline 4 & & \text{选择 $b = 4$} \\ \hline & 1 \quad 10 & \text{裁判选择 $y = 1$ 和 $a = 10$} \\ \hline 10 & & \text{选择 $b = 10$} \\ \hline & 6 \quad 3 & \text{裁判选择 $y = 6$ 和 $a = 3$} \\ \hline 4 & & \text{选择 $b = 4$} \\ \hline & 4 \quad 5 & \text{裁判选择 $y = 4$ 和 $a = 5$} \\ \hline 8 & & \text{选择 $b = 8$} \\ \hline \end{array}

参赛者程序获胜,因为贝尔纳多选择了两本主题编号为 44 的书籍。本交互示例中参赛者与裁判所执行的操作未必是最优的。

输入解题思路,AI测评打分。不知道怎么写?

首页