#include <stdio.h>
int main() {
int data[4] = {120, 110, 140, 150};
int num = 485;
int low,high,mid;
low = 0;
high = 150;
int result,sum = 0;
while(low <= high){
sum = 0;
mid = (low + high) / 2;
for (int i = 0;i < 4;i++) {
if (data[i] > mid){
sum += mid;
}else{
sum += data[i];
}
}
if(sum <= num){
result = mid;
low = mid + 1;
}
else{
high = mid - 1;
}
}
printf("%d",result);
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: