Help me in solving CAMPON problem

My code

``````#include <iostream>
using namespace std;

int main() {
int t;
cin>>t;
while(t--) {
int D;
cin>>D;
int d[D],p[D];
for(int i=0;i<D;i++) {
cin>>d[i]>>p[i];
}
int q;
cin>>q;
for(int i=0;i<q;i++) {
}
int sum=0;
for(int i=0;i<q;i++) {
cout<<"Go Sleep"<<endl;
sum+=p[i];
}
if(p[i]>=req[i]) {
cout<<"Go Camp"<<endl;
}
else {
cout<<"Go Sleep"<<endl;
}
sum+=p[i];
}
sum+=p[i];
if(sum>=req[i]) {
cout<<"Go Camp"<<endl;
}
else {
cout<<"Go Sleep"<<endl;
}
}
}
}
return 0;
}

``````

Problem Link: CAMPON Problem - CodeChef

@yashu_12
your logic was not complete and also made some extra conditions that making the coding wrong i have made some changes in your code u cover all the conditions i hope u will get it.
#include<bits/stdc++.h>
using namespace std;

int main() {
int t;
cin>>t;
while(t–) {
int D;
cin>>D;
int d[D],p[D];
for(int i=0;i<D;i++) {
cin>>d[i]>>p[i];
}
int numberofprb_atdate[32]={0};
int q;
cin>>q;
for(int i=0;i<q;i++) {
}
int sm=0;
for(int i=1,j=0;i<=31;i++)
{
if(i==d[j])
{
sm+=p[j];
numberofprb_atdate[i]=sm;
j++;
}
else
{
numberofprb_atdate[i]=sm;
}
}
for(int i=0;i<q;i++) {