I am getting a wrong answer for HELLO. The logic I used was that instead of calculating for one month, I calculated it for 36 months(as that was the max validity option)and then compare the prices. The sample cases given work fine. But I guess I am missing some corner case. Please help. Thank you!
My code ::
#include <iostream>
#include <stdio.h>
using namespace std;
int main()
{
int cases;
float default_rate, callRate;
int minsLastMonth;
int addons;
int validity, planCost;
float cost;
scanf("%d", &cases);
while(cases--)
{
scanf("%f %d %d", &default_rate, &minsLastMonth, &addons);
float expenditure = minsLastMonth*default_rate*36;
float maxProfit=0;
int index=0;
for(int i=0; i<addons; i++)
{
scanf("%d %f %d", &validity, &callRate, &planCost);
cost=((36/validity)*planCost)+(callRate*minsLastMonth*36);
if(cost<expenditure && (expenditure-cost)>maxProfit)
{
index=i+1;
maxProfit=expenditure-cost;
}
}
printf("%d\n", index);
}
return 0;
}