Help me in solving CHEFSUM problem

My issue

Can anyone help me figure out which test case my code is failing in?

My code

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

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n, ind = -1;
        cin >> n;
        int a[n + 10], prefixSum[n + 10], suffixSum[n + 10];
        prefixSum[0] = suffixSum[n + 1] = 0;
        for (int i = 1; i <= n; cin >> a[i++]);
        for (int i = 1; i <= n; i++)
        {
            prefixSum[i] = prefixSum[i - 1] + a[i];
            suffixSum[n - i + 1] = suffixSum[n - i + 2] + a[n - i + 1];
        }
        int s, sum;
        for (int i = n; i >= 1; i--)
        {
            sum = prefixSum[i] + suffixSum[i];
            if (i == n)
            {
                s = sum;
                ind = n;
            }
            if (s >= sum)
            {
                s = sum;
                ind = i;
            }
        }
        cout << ind << endl;
    }
}

Problem Link: CHEFSUM Problem - CodeChef

It’s night you should sleep otherwise it will effect your health :yawning_face: :yawning_face:
rest till my answer

I checked your profile you got your answer. tq;

What’s the point of a discussion forum if you just had to copy paste a ChatGPT response? I could’ve looked at it myself too, and I am sorry if you misinterpreted, but I need an ACTUAL PERSON to go through my code and tell me the exact issue and not just beat around the bush. All the chatGPT suggestions have been checked for and none of them is the issue.

  • If the online judge can handle N values of up to 10^5, then I’m sure it won’t matter if I take 10 more. Time Complexity remains of the same order.
  • The input loop works perfectly and there’s absolutely no issue with it.
  • The initialisation of s with the last element of the prefixSum is not an issue here because we have to find the least of all the values.

Please learn coding ethics and don’t play around here @abhaypandey114

I understand that you may be frustrated, but please try to express your thoughts in a more respectful manner. It’s important to remember that people here are offering their help . While the ChatGPT response may not have been what you were expecting, it was still an attempt to assist My intent was not to copy and paste a ChatGPT response, but rather to provide you with a starting point. I’m sure someone will be more than willing to review and help you out. Let’s maintain a positive and helpful environment for everyone here.
and I am pulling back what i have suggested you . sorry!!! it was my mistake (my over exiting nature to anyhow comeup with help which doesn’t needed) .