This is my code. It runs correctly with custom example inputs, but fails when I submit it. Also I don't know how to add constraints as given in question. The link to the question is : https://www.codechef.com/submit/HS08TEST.
#include <iostream>
#include<iomanip>
using namespace std;
int main() {
// your code goes here
int r;
cin >> r;
float balance;
cin >> balance;
float amount;
if (r%5==0 && r<balance ){
amount = float(balance - r - 0.5);
cout << fixed;
cout << setprecision(2) << amount;
}
else {
cout<< fixed;
cout << setprecision(2) << balance;
}
return 0;
}