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