What is wrong with my code -- Little Elephant and Candies

#include <stdio.h>
#include <stdlib.h>

int main() {
int iloop, jloop, sum;
int T = 0; // no of test cases
int N = 0; // no of elephants
int C = 0; // no of candies
int *A_k = NULL; // k no of candy for A elephant

//Test case count
scanf("%d", &T);
if ((T < 1) || (T > 1000)) {
    printf ("No\n");
    return 0;
}

// Run loop for T test cases
for (iloop = 1; iloop<= T; iloop++) {
    scanf("%d", &N);
    scanf("%d", &C);
    
if ((N < 1) || (N > 100)) {
    printf ("No\n");
    return 0;
}

if ((C < 1) || (C > 1000000000)) {
    printf ("No\n");
    return 0;
}

    A_k = malloc (sizeof(int)*N);

    //Take input for all A_k 
    for (jloop= 0; jloop < N; jloop++) {
        scanf("%d", &A_k[jloop]);
        if ((A_k[jloop] < 1) && (A_k[jloop] > 10000)) {
            printf ("No\n");
            return 0;
        }
    }

    for (jloop= 0; jloop < N; jloop++) {
        sum += A_k[jloop];
    }
    if (sum > C) {
        printf("No\n");
    } else {
        printf("Yes\n");
    }
}   
return 0;

}

Consider the testcase:

2
2 2
1 1
2 2 
1 1

Edit:

Oh, and you don’t have to waste time verifying the CONSTRAINTS - #2 by ssjgz. Oh, and please either format your code or link to your submission, in future - this is hard to read :slight_smile: