https://www.codechef.com/submit/BGL1215

https://www.codechef.com/submit/BGL1215

i am getting correct answers if my input values are small but when i input large values it didnt work’In debugger the value of variable s is coming not 0 even though i have initialized.
2
10 60000 50000
100000 100000000 5061651 4654 8458 68468 46848 6484854 665448 565656565
5 3 2
2 2 2 4 3
Talking about 1st test case second one runs fine.

hi dear, the link for submission is not showing your solution( perhaps it is due to april long challenge)
assuming that you are having problem due to data type try using long long instead of “int”

Yes i have used longlong only i dont know why is this happening.
Is there any other source i can share you my code?

This is how you link to a submission:

https://www.codechef.com/viewsolution/44519998

Linking to https://www.codechef.com/submit/<problemname> won’t work, as there is nothing in that URL that uniquely identifies a user, nor a specific submission.

1 Like

https://www.codechef.com/viewsolution/44543275

Consider the test input:

1
5 2 1
5 7 3 9 10
1 Like

Thanks finally got accepted , you are great how did you figured it out?
Pls tell
Also i am a newbie so can you suggest resources to improve dsa and topic wise list to follow, will be of great help.

1 Like

I was lazy and couldn’t be bothered to read your code, so I just took the Setter’s solution and modified it to add a random testcase generator:

#include<bits/stdc++.h>
#include <sys/time.h> // TODO - this is only for random testcase generation.  Remove it when you don't need new random testcases!

using namespace std;
int main(int argc, char* argv[])
{
    if (argc == 2 && string(argv[1]) == "--test")
    {
        struct timeval time;
        gettimeofday(&time,NULL);
        srand((time.tv_sec * 1000) + (time.tv_usec / 1000));
        const int T = 1;
        cout << T << endl;

        for (int t = 0; t < T; t++)
        {
            const int N = 1 + rand() % 10;
            int A;
            int B;
            do
            {
                A = 1 + rand() % 10;
                B = 1 + rand() % 10;
            } while (!(B < A));
            cout << N << " " << A << " " << B << endl;
            for (int i = 0; i < N; i++)
            {
                cout << 1 + rand() % 10;
                if (i != N - 1)
                    cout << " ";
            }
            cout << endl;
        }

        return 0;
    }

    int t;
    cin>>t;
    while(t--) {
        int n, A, B;
        cin>>n>>A>>B;

        int C[n]; A -= B;

        for(int i = 0; i < n; i++)
            cin>>C[i];

        int lo = 1, hi = 1000000000;

        while(lo != hi) {
            int mi = (lo + hi) / 2;
            long long int todo = 0;
            for(int i = 0; i < n; i++)
                if(1LL*B * mi < C[i]) {
                    todo += ((C[i] - B * mi - 1) / A) + 1;
                }
            if(todo <= mi)
                hi = mi;
            else
                lo = mi + 1;
        }
        cout<<lo<<'\n';
    }
    return 0;
}

and ran that until I got a testcase for which your and their answer differed.

may i know how to add random test case generator in any code