CF1393B.Applejack and Storages

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

This year in Equestria was a year of plenty, so Applejack has decided to build some new apple storages. According to the advice of the farm designers, she chose to build two storages with non-zero area: one in the shape of a square and another one in the shape of a rectangle (which possibly can be a square as well).

Applejack will build the storages using planks, she is going to spend exactly one plank on each side of the storage. She can get planks from her friend's company. Initially, the company storehouse has nn planks, Applejack knows their lengths. The company keeps working so it receives orders and orders the planks itself. Applejack's friend can provide her with information about each operation. For convenience, he will give her information according to the following format:

  • ++ xx: the storehouse received a plank with length xx
  • −- xx: one plank with length xx was removed from the storehouse (it is guaranteed that the storehouse had some planks with length xx).

Applejack is still unsure about when she is going to order the planks so she wants to know if she can order the planks to build rectangular and square storages out of them after every event at the storehouse. Applejack is busy collecting apples and she has completely no time to do the calculations so she asked you for help!

We remind you that all four sides of a square are equal, and a rectangle has two pairs of equal sides.

今年小马国迎来了丰收之年,因此苹果杰克决定建造一些新的苹果仓库。根据农场设计师的建议,她决定建造两个面积不为零的仓库:一个为正方形,另一个为矩形(该矩形也可能是正方形)。

苹果杰克将使用木板来建造这些仓库,每条边恰好使用一块木板。她可以从朋友的公司获取木板。最初,该公司仓库中有 nn 块木板,苹果杰克已知它们各自的长度。该公司持续运营,会接收订单并自行采购木板。苹果杰克的朋友可以向她提供每次操作的相关信息。为方便起见,他将按如下格式提供信息:

  • ++ xx:仓库新收到一块长度为 xx 的木板;
  • −- xx:仓库中移除了一块长度为 xx 的木板(保证仓库中当时至少有一块长度为 xx 的木板)。

苹果杰克尚不确定何时下单采购木板,因此她希望知道:在仓库每次操作之后,她是否都能从当前库存的木板中选出若干块,用于建造一个矩形仓库和一个正方形仓库。苹果杰克正忙于采摘苹果,完全没时间进行计算,于是她向你求助!

我们提醒你:正方形的四条边长度均相等;矩形则有两组对边,每组中的两条边长度分别相等。

输入格式

The first line contains a single integer nn (1≤n≤1051 \le n \le 10^5): the initial amount of planks at the company's storehouse, the second line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤1051 \le a_i \le 10^5): the lengths of the planks.

The third line contains a single integer qq (1≤q≤1051 \le q \le 10^5): the number of events in the company. Each of the next qq lines contains a description of the events in a given format: the type of the event (a symbol ++ or −-) is given first, then goes the integer xx (1≤x≤1051 \le x \le 10^5).

第一行包含一个整数 nn(1≤n≤1051 \le n \le 10^5):公司仓库中木板的初始数量;
第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤1051 \le a_i \le 10^5):各木板的长度。

第三行包含一个整数 qq(1≤q≤1051 \le q \le 10^5):公司发生的事件总数。
接下来的 qq 行,每行描述一个事件,格式如下:首先给出事件类型(符号 ++ 或 −-),随后是一个整数 xx(1≤x≤1051 \le x \le 10^5)。

输出格式

After every event in the company, print "YES" if two storages of the required shape can be built from the planks of that company's set, and print "NO" otherwise. You can print each letter in any case (upper or lower).

每次公司活动后,若能用该公司套装中的木板建造出两个所需形状的储物柜,则输出 “YES”;否则输出 “NO”。每个字母可使用大写或小写形式输出。

输入输出样例

  • 输入#1

    6
    1 1 1 2 1 1
    6
    + 2
    + 1
    - 1
    + 2
    - 1
    + 2

    输出#1

    NO
    YES
    NO
    NO
    NO
    YES

说明/提示

After the second event Applejack can build a rectangular storage using planks with lengths 11, 22, 11, 22 and a square storage using planks with lengths 11, 11, 11, 11.

After the sixth event Applejack can build a rectangular storage using planks with lengths 22, 22, 22, 22 and a square storage using planks with lengths 11, 11, 11, 11.

第二次事件后,苹果杰克可以使用长度为 11、22、11、22 的木板建造一个矩形储藏室,以及使用长度为 11、11、11、11 的木板建造一个正方形储藏室。

第六次事件后,苹果杰克可以使用长度为 22、22、22、22 的木板建造一个矩形储藏室,以及使用长度为 11、11、11、11 的木板建造一个正方形储藏室。

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

首页