You are viewing a single comment's thread. Return to all comments →
Java solution:
import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int k = scanner.nextInt(); int total = 0; for (int i = 0; i < n; i++) { int price = scanner.nextInt(); if (i != k) total += price; } int charged = scanner.nextInt(); System.out.println(total / 2 == charged ? "Bon Appetit" : charged - (total/2)); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Bill Division
You are viewing a single comment's thread. Return to all comments →
Java solution: