C++ Easy solution BS
\n# Code\n\nclass Solution {\npublic:\n    int n;\n    int bns(int x,vector<int>&v) {\n        int l=0,r=n-1;\n        int res;\n        while(l<=r) {\n        
\n# Code\n```\nclass Solution {\npublic:\n    int n;\n    int bns(int x,vector<int>&v) {\n        int l=0,r=n-1;\n        int res;\n        while(l<=r) {\n            int md=(l+r)/2;\n            if(v[md]<=x) res=md,l=md+1;\n            else r=md-1;\n        }\n        return res;\n    }\n    int maximizeWin(vector<int>& v, int k) {\n        n=v.size();\n        int ans=0;\n        int aa[n+5],bb[n+5];\n        \n        for(int i=0; i<n; i++) {\n            int x=k+v[i];\n            int y=bns(x,v)+1;\n            int p=i;\n            //cout<<y-p<<endl;\n            aa[i]=y-p;\n            \n        }\n        for(int i=n-1; i>=0; i--) {\n            int x;\n            if(i==n-1) x=0;\n            else x=bb[i+1];\n            bb[i]=max(aa[i],x);\n        }\n        for(int i=0; i<n; i++) {\n            int x=0;\n            if(i+aa[i]<n) {\n                x=bb[i+aa[i]];\n            }\n            ans=max(ans,aa[i]+x);\n        }\n        return ans;\n    }\n};\n```
['C++']