We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
int bill[n];
int total = 0;
// Input bill item
for(int i = 0; i < n; i++) {
scanf("%d", &bill[i]);
total += bill[i];
}
int b;
scanf("%d", &b);
// Calculate Anna's actual share
int anna_share = (total - bill[k]) / 2;
if(anna_share == b) {
printf("Bon Appetit");
} else {
printf("%d", b - anna_share);
}
return 0;
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sales by Match
You are viewing a single comment's thread. Return to all comments →
include
int main() { int n, k; scanf("%d %d", &n, &k);
}