Trudny problem z podzbiorem
int isPossible(long long S, long long N, long long X, long long A[])
{
// code here
long long sum = S;
long long idx = N-1 ;
for(long long i=0; i<N ;i++)
{
A[i]= A[i] + sum;
sum = sum + A[i];
if(A[i] >= X)
{
idx=i;
break;
}
}
while(idx>=0)
{
if(X >= A[idx])
X = X - A[idx];
idx--;
}
if( X==0 || X == S) return 1;
return 0;
}
Deep Rakhasiya