CF1776A.Walking Boy

入门

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

One of the SWERC judges has a dog named Boy. Besides being a good competitive programmer, Boy loves fresh air, so she wants to be walked at least twice a day. Walking Boy requires 120120 consecutive minutes. Two walks cannot overlap, but one can start as soon as the previous one has finished.

Boy before and after getting ACCEPTED on this problem.

Today, the judge sent nn messages to the SWERC Discord server. The ii-th message was sent aia_i minutes after midnight. You know that, when walking Boy, the judge does not send any messages, but he can send a message right before or right after a walk. Is it possible that the judge walked Boy at least twice today?

Note that a day has 14401440 minutes, and a walk is considered to happen today if it starts at a minute s≥0s \ge 0 and ends right before a minute e≤1440e \le 1440. In that case, it must hold that e−s=120e - s = 120 and, for every i=1, 2 …, ni = 1, \, 2 \, \dots, \, n, either ai≤sa_i \le s or ai≥ea_i \ge e.

SWERC 的一位裁判养了一只名叫 Boy 的狗。除了是一名优秀的竞赛程序员外,Boy 还非常喜爱新鲜空气,因此她每天至少需要遛两次。每次遛狗需要连续 120 分钟。两次遛狗的时间段不能重叠,但后一次可以紧接在前一次结束的那一刻开始。

Boy 在本题获得 ACCEPTED 前后对比。

今天,该裁判向 SWERC Discord 服务器发送了 nn 条消息。第 ii 条消息在午夜之后 aia_i 分钟发出。已知:裁判在遛 Boy 期间不会发送任何消息,但可以在某次遛狗开始前或结束后立即发送消息。请问:今天裁判是否有可能至少遛了 Boy 两次?

注意:一天共有 14401440 分钟;若一次遛狗从时刻 s≥0s \ge 0(单位:分钟,从午夜起算)开始、在时刻 e≤1440e \le 1440(不包含 ee)结束,则认为该次遛狗发生在今天。此时必须满足 e−s=120e - s = 120,且对每个 i=1,2,…,ni = 1, 2, \dots, n,均有 ai≤sa_i \le s 或 ai≥ea_i \ge e。

输入格式

Each test contains multiple test cases. The first line contains an integer tt (1≤t≤1001 \le t \le 100) — the number of test cases. The descriptions of the tt test cases follow.

The first line of each test case contains an integer nn (1≤n≤1001 \le n \le 100) — the number of messages sent by the judge.

The second line of each test case contains nn integers a1, a2, …, ana_1, \, a_2, \, \dots, \, a_n (0≤a1<a2<⋯<an<14400 \le a_1 \lt a_2 \lt \cdots \lt a_n \lt 1440) — the times at which the messages have been sent (in minutes elapsed from midnight).

每个测试包含多个测试用例。第一行包含一个整数 tt(1≤t≤1001 \le t \le 100),表示测试用例的数量。接下来是 tt 个测试用例的描述。

每个测试用例的第一行包含一个整数 nn(1≤n≤1001 \le n \le 100),表示裁判发送的消息数量。

每个测试用例的第二行包含 nn 个整数 a1, a2, …, ana_1, \, a_2, \, \dots, \, a_n(0≤a1<a2<⋯<an<14400 \le a_1 \lt a_2 \lt \cdots \lt a_n \lt 1440),表示消息发送的时间(以从午夜开始经过的分钟数计)。

输出格式

For each test case, output one line containing YES\texttt{YES} if it is possible that Boy has been walked at least twice, and NO\texttt{NO} otherwise.

对于每个测试用例,如果男孩可能至少走过某条路径两次,则输出一行 YES\texttt{YES};否则输出 NO\texttt{NO}。

输入输出样例

  • 输入#1

    6
    14
    100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400
    12
    100 200 300 400 600 700 800 900 1100 1200 1300 1400
    13
    100 200 300 400 500 600 700 800 900 1100 1200 1300 1400
    13
    101 189 272 356 463 563 659 739 979 1071 1170 1274 1358
    1
    42
    5
    0 1 2 3 4

    输出#1

    NO
    YES
    NO
    YES
    YES
    YES

说明/提示

In the first test case, the judge has sent a message at each time multiple of 100100 (excluding 00). It is impossible that he has walked Boy even once.

In the second test case, the times are the same as above, but 500500 and 10001000 are missing. The judge could have walked Boy, for instance, during the time intervals [440,560][440, 560] and [980,1100][980, 1100]. The situation is illustrated in the picture below, where the walks are represented by green intervals.

In the third test case, the times are the same as in the first test case, but 10001000 is missing. The judge could have walked Boy at most once.

In the fourth test case, Boy could have been walked during the time intervals [739,859][739, 859] and [859,979][859, 979].

在第一个测试用例中,裁判在每个 100100 的倍数时刻(不包括 00)都发送了一条消息。此时裁判不可能曾带 Boy 散过步。

在第二个测试用例中,发送消息的时刻与上一例相同,但缺少了 500500 和 10001000 这两个时刻。裁判有可能带 Boy 散过步,例如在时间区间 [440,560][440, 560] 和 [980,1100][980, 1100] 内。该情形如下图所示,其中散步区间用绿色表示。

在第三个测试用例中,发送消息的时刻与第一个测试用例相同,但缺少了 10001000 这一时刻。此时裁判最多只能带 Boy 散一次步。

在第四个测试用例中,Boy 可能在时间区间 [739,859][739, 859] 和 [859,979][859, 979] 内被带出去散步。

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

首页