O(nlogn), max size subsequence
\n\n# Code\n\nclass Solution {\npublic:\n    int kIncreasing(vector<int>& a, int k) {\n        int n = a.size(),ans=0;\n        if(k==n)return 0;\n        for(i
\n\n# Code\n```\nclass Solution {\npublic:\n    int kIncreasing(vector<int>& a, int k) {\n        int n = a.size(),ans=0;\n        if(k==n)return 0;\n        for(int i=0;i<k;i++){\n            vector<int> v;\n            int j=i;\n            for(j=i;j<n;j+=k){\n                if(v.size()==0||v.back()<=a[j])v.push_back(a[j]);\n                else {\n                    auto it=upper_bound(v.begin(),v.end(),a[j])-v.begin();\n                    v[it]=a[j];\n                }\n            }\n            ans+= (n-i+k-1)/k - v.size();\n        }\n        return ans;\n    }\n};\n```
['C++']