CF1101E.Polycarp's New Job
普及/提高-
通过率:0%
时间限制:3.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Polycarp has recently got himself a new job. He now earns so much that his old wallet can't even store all the money he has.
Berland bills somehow come in lots of different sizes. However, all of them are shaped as rectangles (possibly squares). All wallets are also produced in form of rectangles (possibly squares).
A bill x×y fits into some wallet h×w if either x≤h and y≤w or y≤h and x≤w. Bills can overlap with each other in a wallet and an infinite amount of bills can fit into a wallet. That implies that all the bills Polycarp currently have fit into a wallet if every single one of them fits into it independently of the others.
Now you are asked to perform the queries of two types:
- + x y — Polycarp earns a bill of size x×y;
- ? h w — Polycarp wants to check if all the bills he has earned to this moment fit into a wallet of size h×w.
It is guaranteed that there is at least one query of type 1 before the first query of type 2 and that there is at least one query of type 2 in the input data.
For each query of type 2 print "YES" if all the bills he has earned to this moment fit into a wallet of given size. Print "NO" otherwise.
波利卡普最近找到了一份新工作。他现在的收入如此之高,以至于他旧的钱包甚至无法容纳他所拥有的全部钞票。
伯兰国的纸币尺寸多种多样,但它们全都是矩形(也可能是正方形)。所有钱包也都是矩形(也可能是正方形)形状。
一张尺寸为 x×y 的纸币可以放入一个尺寸为 h×w 的钱包中,当且仅当满足以下两个条件之一:
- x≤h 且 y≤w,或
- y≤h 且 x≤w。
纸币在钱包中可以相互重叠,且一个钱包可容纳无限数量的纸币。这意味着:波利卡普当前拥有的所有纸币都能放入某个钱包中,当且仅当其中每一张纸币都可独立地放入该钱包(不考虑其他纸币的存在)。
现在你需要处理两类查询:
- + x y — 波利卡普获得了一张尺寸为 x×y 的纸币;
- ? h w — 波利卡普想检查:截至目前他所获得的所有纸币是否都能放入一个尺寸为 h×w 的钱包中。
保证在第一个类型 2 的查询之前,至少存在一个类型 1 的查询;且输入数据中至少包含一个类型 2 的查询。
对每个类型 2 的查询,请输出 "YES",如果截至目前他所获得的所有纸币都能放入给定尺寸 h×w 的钱包中;否则输出 "NO"。
输入格式
The first line contains a single integer n (2≤n≤5⋅105) — the number of queries.
Each of the next n lines contains a query of one of these two types:
- + x y (1≤x,y≤109) — Polycarp earns a bill of size x×y;
- ? h w (1≤h,w≤109) — Polycarp wants to check if all the bills he has earned to this moment fit into a wallet of size h×w.
It is guaranteed that there is at least one query of type 1 before the first query of type 2 and that there is at least one query of type 2 in the input data.
第一行包含一个整数 n(2≤n≤5⋅105),表示查询次数。
接下来的 n 行中,每行包含以下两种类型之一的查询:
- + x y(1≤x,y≤109)—— Polycarp 获得了一张尺寸为 x×y 的钞票;
- ? h w(1≤h,w≤109)—— Polycarp 想检查当前他所获得的所有钞票是否都能放入一个尺寸为 h×w 的钱包中。
保证在第一个类型 2 的查询之前,至少存在一个类型 1 的查询;且输入数据中至少包含一个类型 2 的查询。
输出格式
For each query of type 2 print "YES" if all the bills he has earned to this moment fit into a wallet of given size. Print "NO" otherwise.
对于每个类型为 2 的查询,如果他到目前为止所获得的所有钞票都能放入给定尺寸的钱包中,则输出 "YES";否则输出 "NO"。
输入输出样例
输入#1
9 + 3 2 + 2 3 ? 1 20 ? 3 3 ? 2 3 + 1 5 ? 10 10 ? 1 5 + 1 1
输出#1
NO YES YES YES NO
说明/提示
The queries of type 2 of the example:
- Neither bill fits;
- Both bills fit (just checking that you got that bills can overlap);
- Both bills fit (both bills are actually the same);
- All bills fit (too much of free space in a wallet is not a problem);
- Only bill 1×5 fit (all the others don't, thus it's "NO").
示例中类型为 2 的查询:
- 两张纸币都无法放入;
- 两张纸币均可放入(仅用于验证:你已理解纸币可以重叠);
- 两张纸币均可放入(实际上两张纸币完全相同);
- 所有纸币均可放入(钱包中留有过多空余空间并不构成问题);
- 仅 1×5 的纸币可以放入(其余所有纸币均无法放入,因此答案为 “NO”)。
输入解题思路,AI测评打分。不知道怎么写?