Help me in solving SUPINC problem

My code

#include<bits/stdc++.h>
using namespace std;
int main(){
    int t;cin>>t;
    while(t--){
        long long int n,x,k;cin>>n>>x>>k;
        long long int a[n+1];
        a[0]=0;
        a[1]=1;
        a[x]=k;
        long long int sum=0;
        for(int i=1;i<=x;i++){
            sum=sum+a[i-1];
            a[i]=sum+1;
            
        }
        if(k<=sum){cout<<"NO"<<endl;}
        else cout<<"YES"<<endl;
    }
}

Problem Link: Superincreasing Practice Coding Problem - CodeChef

You long longs are overflowing. You should try another apprach.

hello actully here four mistake in your code
1st is reading input (n, x, k) but write in (n, k, x)
2nd is array index issue like You are directly assigning a[x] = k;, but x is meant to be the value at k-th index (a[k] = X). you Use a[k] = X; instead of a[x] = k;.
3rd is incorrect array initilization like You are overwriting a[i] inside the loop without checking if it’s already assigned (a[k] = X). Avoid changing a[k] inside the loop.
4th is You should ensure a[i] > sum for every index.
If i == K, check if X > sum, otherwise generate values normally.

I corrected your code if you want you can update your code.
You are using long long int a[n+1];, which is not recommended because n can be large (2 × 10^5). Declaring large arrays locally may cause stack overflow.
Use dynamic memory allocation with vector<long long> instead

#include <bits/stdc++.h>
using namespace std;

int main() {
    int t;
    cin >> t;
    while (t--) {
        long long int n, k, x;
        cin >> n >> k >> x;
        vector<long long> a(n + 1, 0);

        a[1] = 1;
        long long sum = 0;

        for (int i = 1; i <= n; i++) {
            if (i == k) {
                if (x <= sum) {
                    cout << "No" << endl;
                    goto next_case;
                }
                a[i] = x;
            } else {
                a[i] = sum + 1;
            }
            sum += a[i];
        }

        cout << "Yes" << endl;
    next_case:;
    }
    return 0;
}

I tried this approach, you can also try if it work for you or not because there is two hidden test case are not pass with this code. hope you can more modify it.