about CAMPON problem of December Cook-Off 2018 Division 2

Hey I am getting successfully executed for the “CAMPON” problem in online compiler of codechef. But when I am trying to submit the code, at that time it is giving Wrong Answer.
But my answer is correct.
Please help me…

Here is my Code for CAMPON problem of December Cook-Off 2018 Division 2:

#include
using namespace std;

int T, D, Q;

bool camp_or_not(int* d, int* p, int dead, int req){
int sum = 0;
bool res = false;

for(int i=0;i<D;i++){
	if(dead > d[i]){
		sum += p[i];
		if(sum >= req) return true;
	}
}
return false;

}
int main(){

//int T, D, Q;
cin>>T;
while(T--){
	cin>>D;
	int d[D], p[D];
	for(int i=0;i<D;i++){
		cin>>d[i]>>p[i];
	}
	cin>>Q;
	int dead[Q], req[Q];
	for(int i=0;i<Q;i++){
		cin>>dead[i]>>req[i];
		int res = camp_or_not(d, p, dead[i], req[i]);
		if(res)	cout<<"Go Camp\n";
		else cout<<"Go Sleep\n";
	}


}

return 0;

}

Hey,
The thing is that you have tested your program only on the given sample cases and there are many other hidden cases for which your program wasn’t able to give the right answer and hence your code is giving you verdict as WA. Try your code on some more sample cases and try to debug your code and then resubmit your code.

Here’s your solution which passes all the test cases with some minor modifications made by me. I’d encourage you to spot the mistakes by yourself or if you are stuck, look at your AC solution for hints.

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

@ashishnar_123 i think you should do like this if(dead>=d[i)…

I am facing same issue, I am new to codecheff, so m not really familiar with how testing here works. But I feel pretty sure about my code, any help would be appreciated.

#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ull unsigned long long


int main()
{
    SPEED;
    int t;
    cin>>t;
    while(t--)
    {
    	int n, d ,p, q, d1, p1, prev = 0;
    	cin>>n;
    	vector<int> ded;
    	int probs[n];
    	for(int i = 0; i < n; i++)
    	{
    		    cin>>d>>p;
		        ded.push_back(d);
		        probs[i] = p + prev;
		        prev = probs[i];
    	}
    	cin>>q;
    	while(q--)
    	{
    		cin>>d1>>p1;
    		int index = lower_bound(ded.begin(), ded.end(), d1) - ded.begin();
    		
    		if(ded[index] != d1)
    			index--;
    	
    		//cout<<index<<"\n";
    		if(index < 0)
    			cout<<"Go Sleep\n";
    		
    		else if(probs[index] < p1)
    			cout<<"Go Sleep\n";
    		
    		else
    			cout<<"Go Camp\n";
    		
    	}
    }
   
    return 0;
}

actually when I am running this code on online compiler of codechef then it is getting accepted but it shows WA while submitting.
so on online compiler all the test cases getting pass.

The online compiler of codechef is like any other ide. When you run your code on the compiler, it runs your code on the test cases which need to be entered by you manually. And hence your code has some mistakes which you need to spot and then enter the test cases manually.