Winning CB Scholarship only 2 test cases passing

#include
using namespace std;
int main(){
long long int stu,coupan,req,pen;
cin>>stu>>coupan>>req>>pen;
long long int got;
long long int rem_stu;
long long int coup_rem;
long long int req_coupan = stu * req;
long long int p = coupan;

if(coupan == req_coupan) cout<<stu;
if(coupan>req_coupan) cout<<stu;
else if(coupan<req_coupan){
	long long int cnt=0;
	int i=1;
	while(p>0){
		p = p-req*i;
		cnt++;
	}
	got = cnt;
	
	rem_stu = stu - got;
	coup_rem = coupan - got*req;
	
	if((rem_stu*pen + coup_rem)<req) cout<<got<<endl;
	else cout<<got+((rem_stu*pen + coup_rem)/req)<<endl;

}

}

hi @panditabhi29263,
it is a binary search problem
you have apply binary search on 0 to N (no of students)
and divide them into those who got waiver and who perform badly

now try with this hint

if not able to solve you can take help from this code