-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodeup 3321.cpp
More file actions
60 lines (49 loc) · 871 Bytes
/
codeup 3321.cpp
File metadata and controls
60 lines (49 loc) · 871 Bytes
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
#include <algorithm>
using namespace std;
bool compare(int a, int b)
{
return a > b;
}
int main()
{
int topping = 0;
int pizza = 0;
int toPrice = 0;
int pizzaKcal[100] = {0, };
cin >> topping;
cin >> pizza >> toPrice;
int toNum[100] = { 0, };
int pKcal = 0;
cin >> pKcal;
for (int i = 0; i < topping; i++)
{
int k;
cin >> k;
toNum[i] = k;
}
sort(toNum, toNum + topping, compare);
int i = 0;
int totalPrice[100] = { 0, };
int num = topping;
while (num != 0)
{
int A = 0;
for (int i = 0; i < num; i++)
{
A += toNum[i];
}
pizzaKcal[i] = A + pKcal;
totalPrice[i] = pizza + (toPrice * num);
num--;
i++;
}
int result[100] = { 0, };
for (int i = 0; i < topping; i++)
{
result[i] = pizzaKcal[i] / totalPrice[i];
}
sort(result, result + topping, compare);
cout << result[0] << endl;
return 0;
}