CHEFEZQ - Editorial

My code is working in my PC, then why is it not working on the editor of Codechef. Please help

import java.util.*;
class Main{
public static void main(String[] args){
Scanner sc = new Scanner (System.in);
System.out.println(“Enter the number of test cases”);
int testcases = sc.nextInt();
sc.nextLine();

    while(testcases > 0){
        System.out.println("Enter the values of n and k, respectively");
        String str = sc.nextLine();
        String[] array = str.split(" ");
        int n = Integer.parseInt(array[0]);
        int k = Integer.parseInt(array[1]);

        System.out.println("Enter the number of queries in consecutive days");
        String strs = sc.nextLine();
        String[] arrays = strs.split(" ");
        int[] arr = new int[n];
        for (int i = 0; i < n; i++){
            arr[i] = Integer.parseInt(arrays[i]);
        }

        int sum = 0, count = 0;

        for (int i = 0; i<n; i++){
            sum = sum + arr[i];
            if (arr[i] < k){
                if (sum < (i+1)*k){
                    count = i+1;
                    break;
                }
            }
        }
        if (count == 0) {
            count = (sum/k)+1;
        }
        System.out.println(count);

        testcases--;
    }
}

can anybody tell me why I am failling subtask 1 but passing subtask 2.
Here is my solution in c++.

The Code is failing on subtask-1 !!! I am not being able to find the issue ???

``#include<bits/stdc++.h>

using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long

int main()
{
FAST_IO;
long T;
cin >> T;

while(T--)
{
	ll n,k,q,a=0,day;
	cin >> n >> k;

	bool ans = false;

	// reading the input 
	for(ll i=0; i<n; i++)
	{
		cin >> q;
		a = (q+a);

		if((a-k) < 0)
		{	ans = true;
			day = (i+1);
			break;
		}

		else
		{
			a = a-k;
		}
	}

	if(!ans)
	{
		day =  (n+ (a/k)+1);
	}

	cout << day << endl;

}

return 0;

}``

can you plz tell me why we have to use long long here

https://www.codechef.com/viewsolution/38992356
I solved the https://www.codechef.com/status/CHEFEZQ problem, but I got an 80 only, I got RE(SIGFPE) error which generally comes when a number is divided by zero, which is not possible for my case. I tried to solves that error for an hour. Could someone please help me solve this?

For ease, I am putting my code here:
#include
using namespace std;

int main() {
// your code goes here
long long t;
cin>>t;
while(t–)
{
long long n,k;
cin>>n>>k;
long long acc = 0,q,i=0;
bool flag= false;
for(i=0;i<n;i++)
{
cin>>q;
acc += q;
acc -= k;
if(acc<0)
{
flag = true;
break;
}
}
i = (flag)?i+1:n+(acc/k)+1;

        cout<<i<<endl;
        
    }
    
return 0;

}

//NODEJS
process.stdin.resume();
process.stdin.setEncoding('utf8');

let read = '';

process.stdin.on('data' , function(chunk){read+=chunk});

process.stdin.on('end' , function(){
    let input = read.split('\n');
    let counter = 0;
    let t = input[counter++];
    for(let i = 0; i<t; i++){
        let nk = input[counter++].split(' ').map(Number);
        //console.log(nk);
        let n = nk[0];
        let k = nk[1];
        let kNumbers = input[counter++].split(' ').map(Number);
        let temp = 0;
        for(let j = 0; j<kNumbers.length; j++){
            temp+=kNumbers[j];
            if(temp<k){
                console.log(j+1);
            }
            temp-=k;
        }
        if(temp>=k){
            temp = Math.floor(temp/k)+1;
            console.log(temp + n);
        }
    }
    
}); 

I don’t know why the sub task 1 is failed with error WA. Can someone help me? Is there anything wrong with the above code?