as we are using compare her
like if
money =1 00 it will check a<=100 and we will get index of 100.
similarly for money =1 20 a<=120 and we will get index of 100.
what do we need to subtract 1 than while finding lb;
#include
#include
using namespace std;
bool compare(int a,int b){
return a<=b;
}
int main() {
int coin[]={1,2,5,10,20,50,100,200,500,1000};
int n = sizeof(coin)/sizeof(coin[0]);
int money;
cin>>money;
int lb = lower_bound(coin,coin+n,money,compare) - coin-1;
cout<<lb<<endl;
cout<<coin[lb];
}