-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbon apetite
36 lines (26 loc) · 1005 Bytes
/
bon apetite
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner scan = new Scanner(System.in);
int items = scan.nextInt();
int didNotEat = scan.nextInt();
double[] costArray = new double[items];
for(int i = 0; i < items; i++)
costArray[i] = scan.nextDouble();
int annaPaid = scan.nextInt();
double runningCost = 0;
for(int i = 0; i < items; i++){
if(i == didNotEat)
continue;
else{
runningCost += costArray[i] / 2.0;
}
}
if((int)Math.round(runningCost) == annaPaid)
System.out.print("Bon Appetit");
else
System.out.print(annaPaid - (int)Math.round(runningCost));
}
}