using segmentree concept
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public List<Boolean> ans;\n    public int [] segTree;\n    public List<Boolean> getResults(int[][] q) {\n        ans=new ArrayList<>();\n        int m=q.length;\n        int n=50001;\n        segTree=new int[2*n];\n        segTree[n]=1000000;\n        for(int i=n-1;i>0;i--){\n            segTree[i]=Math.max(segTree[i*2],segTree[i*2+1]);\n        }\n        TreeSet<Integer> set=new TreeSet<>();\n        set.add(0);\n        set.add(1000000);\n        for(int i=0;i<m;i++){\n            if(q[i][0]==1){\n                int x=q[i][1];\n                int prev=set.floor(x);\n                int next=set.ceiling(x);\n                set.add(x);\n                modify(prev, x-prev, n);\n                modify(x, next-x, n);\n            }else{\n                 int x = q[i][1];\n                int sz = q[i][2];\n                if(sz > x) {\n                    ans.add(false);\n                    continue;\n                }\n                int max = query(0, x-sz, n);\n                ans.add(max >= sz);\n            }\n        }\n        \n        return ans;\n    }\n    \n    public void modify(int idx, int val, int n) {\n        idx += n;\n        segTree[idx] = val;\n        idx/=2;\n        while(idx > 0) {\n            segTree[idx] = Math.max(segTree[idx*2], segTree[idx*2+1]);\n            idx/=2;\n        }\n    }\n\n    public int query(int l, int r, int n) { //interval [l, r]\n        int res = 0;\n        l+=n; r+=n;\n        while(l<=r) {\n            if(l%2==1) res = Math.max(res, segTree[l++]);\n            if(r%2==0) res = Math.max(res, segTree[r--]);\n            l/=2; r/=2;\n        }\n        return res;    \n        \n    }\n}\n```
['Java']