Is it possible to calculate the gift amount in O(1) ?
for(int j=0; j<6; ++j) is already O(1). There's no input value that increases the running time of this loop.
for(int j=0; j<6; ++j)