#include <stdio.h>
int main() {
int data[4] = {10, 15, 17, 20};
int target = 7;
int low,high;
low = 1;
high = 20;
int result = -1;
while(low <= high){
int mid = (low + high) / 2;
int sum = 0;
for (int i = 0;i < 4;i++) {
if (data[i] > mid) {
sum += data[i] - mid;
}
}
if (sum >= target) {
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: