WARRIORS - Code working correctly except on CodeChef

I am solving the problem WARRIORS. My Code is running correctly on my local machine as well as other IDE’s on sample test cases, but not on CodeChef.
Error is that my Code gives Wrong Answer
I can’t figure out what’s wrong with my code.

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

long int kills(std::vector<long double> &Fight, long int X, long int N)
{	
	for (long int i = 0; i < N; ++i)
	{
		if(Fight[i]>=X)
			return i;
	}

	return N;
}

int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);

	int test_cases; cin>>test_cases;
	for (int i = 0; i < test_cases; ++i)
	{
		long int N, Q; cin>>N>>Q;
		long int X;
		
		std::vector<long int> P(N,0);
		std::vector<long double> Fight(N,0);
		
		for (long int j = 0; j < N; ++j)
			scanf("%ld",&P[j]);

		sort(P.begin(),P.end());

		Fight[0]=P[0];
		
    //Stores the min energy level required for every next fighter
		for (long int j = 1; j < N; ++j)
			Fight[j]=Fight[j-1]+double(P[j])/double(pow(2.0,j));
		
		for (long int j = 0; j < Q; ++j)
		{ scanf("%ld",&X); 
		  cout<< kills(Fight,X,N)<<'\n';}
	}
	
}
1 Like

same happened with me too. +1