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:

  1. + x y — Polycarp earns a bill of size x×y ;
  2. ? 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.

Input

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:

  1. + x y (1≤x,y≤109 ) — Polycarp earns a bill of size x×y ;
  2. ? 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.

Output

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.

Example

Input
9
+ 3 2
+ 2 3
? 1 20
? 3 3
? 2 3
+ 1 5
? 10 10
? 1 5
+ 1 1
Output
NO
YES
YES
YES
NO

Note

The queries of type 2 of the example:

  1. Neither bill fits;
  2. Both bills fit (just checking that you got that bills can overlap);
  3. Both bills fit (both bills are actually the same);
  4. All bills fit (too much of free space in a wallet is not a problem);
  5. Only bill 1×5 fit (all the others don't, thus it's "NO").

题目大意:

+ 代表给你的money,再给你两个数字,代表长和宽,?代表钱包,问你在出现?前面所有的Money是不是可以装进钱包,可以输出YES,否则输出NO

思路:先对输入数字进行处理,a,b, 输入之后,进行处理,a<b.

出现?,进行查找,很容易可以发现,这里的a一定要比前面所有的a中最大的一个还要大,这里的b同理

否则就装不下所有的。

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn=2e5+10; int main()
{
int n,maxx=0,maxy=0;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
int a,b;
char c[10];
scanf("%s",c);
scanf("%d%d",&a,&b);
if(a>b) swap(a,b);
if(c[0]=='+')
{
maxx=max(maxx,a);
maxy=max(maxy,b);
}
if(c[0]=='?')
{
if(a>=maxx&&b>=maxy) printf("YES\n");
else printf("NO\n");
}
}
return 0;
}

  

贪心 C - Polycarp's New Job的更多相关文章

  1. Codeforces Round #375 (Div. 2) C. Polycarp at the Radio 贪心

    C. Polycarp at the Radio time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  2. CF 1006B Polycarp's Practice【贪心】

    Polycarp is practicing his problem solving skill. He has a list of n problems with difficulties a1,a ...

  3. CodeForces 1005D Polycarp and Div 3(思维、贪心、dp)

    http://codeforces.com/problemset/problem/1005/D  题意: 给一个仅包含数字的字符串,将字符串分割成多个片段(无前导0),求这些片段里最多有多少是3的倍数 ...

  4. 【Codeforces 723C】Polycarp at the Radio 贪心

    n个数,用最少的次数来改变数字,使得1到m出现的次数的最小值最大.输出最小值和改变次数以及改变后的数组. 最小值最大一定是n/m,然后把可以改变的位置上的数变为需要的数. http://codefor ...

  5. Codeforces Round #375 (Div. 2) Polycarp at the Radio 优先队列模拟题 + 贪心

    http://codeforces.com/contest/723/problem/C 题目是给出一个序列 a[i]表示第i个歌曲是第a[i]个人演唱,现在选出前m个人,记b[j]表示第j个人演唱歌曲 ...

  6. cf723c Polycarp at the Radio

    Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be re ...

  7. codeforces 723C : Polycarp at the Radio

    Description Polycarp is a music editor at the radio station. He received a playlist for tomorrow, th ...

  8. Codeforces Round #375 (Div. 2) A B C 水 模拟 贪心

    A. The New Year: Meeting Friends time limit per test 1 second memory limit per test 256 megabytes in ...

  9. CF Covered Path (贪心)

    Covered Path time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

随机推荐

  1. 转:VB中的API详解

    在接下来的这篇文章中,我将向大家介绍.NET中的线程API,怎么样用C#创建线程,启动和停止线程,设置优先级和状态. 在.NET中编写的程序将被自动的分配一个线程.让我们来看看用C#编程语言创建线程并 ...

  2. C# 未能加载文件或程序集“ Newtonsoft.Json” Json格式错误

    原因:版本不一致,所使用的dll和配置文件中的版本不一致.解决: (1)查看所使用的Newtonsoft.Json.dll版本 ,然后把对应的版本修改在配置文件中如下,比如版本为“4.5.0.0” 修 ...

  3. 【redis】6、redis常用命令

    [开启redis客户端,执行redis命令]    redis-cli -h 192.168.1.27 -a HoomSun1 [批量执行redis命令.把命令写到txt中,批量执行]  cat /t ...

  4. junit单元测试注意的问题

    1.有返回值的方法不能直接测试 2.带参数的方法不能直接测试 3.访问权限在public一下的方法不能直接测试 4.static静态方法不能直接测试 5.不能给出现前四个条件中任意一个的方法添加@Te ...

  5. php环境安装

    Windows安装 下载php压缩包, http://php.net/downloads.php, 一定要下载Windows版本的呦 将压缩包解压到指定目录下: 创建配置文件, 其中有两个配置文件在根 ...

  6. angular $watch 一个变量的变化

    $scope.$watch('custArea', function(newValue, oldValue) { angular.forEach(newValue, function(item, ke ...

  7. @Value取不到值的原因(引用application.properties中自定义的值)

    在spring mvc架构中,如果希望在程序中直接使用properties中定义的配置值,通常使用一下方式来获取: @Value("${tag}") private String ...

  8. phpcms有二级导航并且高亮效果代码

    <div class="collapse navbar-collapse" id="example-navbar-collapse"> <ul ...

  9. CentOS7防火墙firewalld设置

    添加80端口  重启后永久生效 firewall-cmd --zone=public --add-port=80/tcp --permanent   查看防火墙状态 systemctl status ...

  10. web框架的本质

    一 web框架的本质及自定义web框架 我们可以这样理解:所有的Web应用本质上就是一个socket服务端,而用户的浏览器就是一个socket客户端,基于请求做出响应,客户都先请求,服务端做出对应的响 ...