-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path1357.cpp
More file actions
25 lines (21 loc) · 694 Bytes
/
Copy path1357.cpp
File metadata and controls
25 lines (21 loc) · 694 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
class Cashier {
uint16_t price[201];
uint16_t n, crnt = 0;
double discount;
public:
Cashier(int n, int discount, const vector<int> &products, const vector<int> &prices)
: n(n), discount((double)(100 - discount) / 100.0) {
for (int i = 0; i < products.size(); i++)
this->price[products[i]] = prices[i];
}
double getBill(const vector<int> &product, const vector<int> &amount) {
uint32_t total = 0;
for (uint8_t i = 0; i < product.size(); i++)
total += price[product[i]] * amount[i];
if (++crnt == n) {
crnt = 0;
return total * discount;
}
return total;
}
};