贪心 C - Polycarp's New Job

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 贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Jobx×y fits into some wallet 贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Jobh×w if either 贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Jobx≤h and 贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Joby≤w or 贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Joby≤h and 贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Jobx≤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. 贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job+ x y — Polycarp earns a bill of size 贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Jobx×y ;
  2. 贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job? h w — Polycarp wants to check if all the bills he has earned to this moment fit into a wallet of size 贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Jobh×w .

It is guaranteed that there is at least one query of type 贪心 C - Polycarp's New Job1 before the first query of type 贪心 C - Polycarp's New Job2 and that there is at least one query of type 贪心 C - Polycarp's New Job2 in the input data.

For each query of type 贪心 C - Polycarp's New Job2 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 贪心 C - Polycarp's New Jobn (贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job2≤n≤5⋅105 ) — the number of queries.

Each of the next 贪心 C - Polycarp's New Jobn lines contains a query of one of these two types:

  1. 贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job+ x y (贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job1≤x,y≤109 ) — Polycarp earns a bill of size 贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Jobx×y ;
  2. 贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job? h w (贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job1≤h,w≤109 ) — Polycarp wants to check if all the bills he has earned to this moment fit into a wallet of size 贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Jobh×w .

It is guaranteed that there is at least one query of type 贪心 C - Polycarp's New Job1 before the first query of type 贪心 C - Polycarp's New Job2 and that there is at least one query of type 贪心 C - Polycarp's New Job2 in the input data.

Output

For each query of type 贪心 C - Polycarp's New Job2 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 贪心 C - Polycarp's New Job2 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 贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job贪心 C - Polycarp's New Job1×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;
}

  

上一篇:flask render_template doesn‘t work on AJAX post


下一篇:ubuntu系统重装记录