E. 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 ?×?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 11 before the first query of type 22 and that there is at least one query of type 22 in the input data.

For each query of type 22 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≤?≤5⋅1052≤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≤?,?≤1091≤x,y≤109) — Polycarp earns a bill of size ?×?x×y; 
  2. ? ℎ ?? h w (1≤ℎ,?≤1091≤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 11 before the first query of type 22 and that there is at least one query of type 22 in the input data.

Output

For each query of type 22 print "YES" if all the bills he has earned to this moment fit into a wallet of given size. Print "NO" otherwise.

这道题卡时间卡的好厉害 用cin cout就超时。。

#include <cstdio>
#include <cstring>
#include<iostream>
#include<cmath>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    ll n;
    ll x,y;
    char ch;
    scanf("%lld",&n);
    getchar();
    ll m1=0,m2=0;
    while(n--){
        scanf("%c %I64d %I64d",&ch,&x,&y);
        getchar();
        if(x>y){
            swap(x, y);
        }
        if(ch=='+'){
            if(x>m1)m1=x;
            if(y>m2)m2=y;
        }
        else{
            if(x>=m1&&y>=m2){
                printf("YES\n");
            }
            else
                printf("NO\n");
        }
    }
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值