Vijay Kumar46w

thank you

Read more… (2 words)

Active In

Competitive Programming

Indian Computing Olympiad (ICO)

Algorithms and Data Structures

Featured Contributions

reply in this discussion

reply in this discussion

Vijay Kumar46w

can someone please help in this question

if have two states dp[i][0] mean ith not selected

dp[i][1] means ith selected

and i have also added code to handle circular condition

#include<bits/stdc++.h>using namespace std;static int arr[10000000],dp[10000000][2];int main(){int t,i,j,k,l,m,n;scanf("%d",&n);for(i=0;i<n;i++){scanf("%d",&arr[i]);}dp[0][1]=arr[0];dp[0][0]=0;dp[1][1]=arr[1];dp[1][0]=dp[0][1];

Read more… (30 words)

reply in this discussion

Vijay Kumar47w

sort array

then for each i bw o to n-1 do log(n) by binary search

i.e. for indx i , find first smallest index j, such that arr[i]+arr[j]>=k

n-j (approx +-1 ) is variation of the that ith indx

add for all i

Read more… (43 words)