728x90
반응형
문제 : 해커랭크 - Bon Appétit
https://www.hackerrank.com/challenges/bon-appetit/problem
난이도: Easy
언어 : C++
// Complete the bonAppetit function below.
void bonAppetit(vector<int> bill, int k, int b) {
int annaToChargeSum = 0;
int toRefund = 0;
for(int i = 0 ;i<bill.size();i++)
{
if(i!=k)
annaToChargeSum+=bill[i];
}
annaToChargeSum=annaToChargeSum/2;
toRefund = b-annaToChargeSum ;
toRefund == 0 ?
cout <<"Bon Appetit" <<endl:
cout <<toRefund <<endl;
}
728x90
반응형
'개발 > 코딩' 카테고리의 다른 글
해커랭크(HackerRank) - Drawing Book / C++ (0) | 2020.06.30 |
---|---|
해커랭크(HackerRank) - Climbing the Leaderboard / C++ (0) | 2020.06.29 |
해커랭크(HackerRank) - Insert a Node at the Tail of a Linked List / C++ (0) | 2020.02.13 |
해커랭크(HackerRank) - Left Rotation / C++ (0) | 2020.02.11 |
해커랭크(HackerRank) - 2D Array - DS / C++ (0) | 2020.02.11 |
댓글