classCashier:def__init__(self,n:int,discount:int,products:List[int],prices:List[int]):self.i=0self.n=nself.discount=discountself.d={product:priceforproduct,priceinzip(products,prices)}defgetBill(self,product:List[int],amount:List[int])->float:self.i+=1discount=self.discountifself.i%self.n==0else0ans=0forp,ainzip(product,amount):x=self.d[p]*aans+=x-(discount*x)/100returnans# Your Cashier object will be instantiated and called as such:# obj = Cashier(n, discount, products, prices)# param_1 = obj.getBill(product,amount)
classCashier{privateinti;privateintn;privateintdiscount;privateMap<Integer,Integer>d=newHashMap<>();publicCashier(intn,intdiscount,int[]products,int[]prices){this.n=n;this.discount=discount;for(intj=0;j<products.length;++j){d.put(products[j],prices[j]);}}publicdoublegetBill(int[]product,int[]amount){intdis=(++i)%n==0?discount:0;doubleans=0;for(intj=0;j<product.length;++j){intp=product[j],a=amount[j];intx=d.get(p)*a;ans+=x-(dis*x)/100.0;}returnans;}}/** * Your Cashier object will be instantiated and called as such: * Cashier obj = new Cashier(n, discount, products, prices); * double param_1 = obj.getBill(product,amount); */
classCashier{public:Cashier(intn,intdiscount,vector<int>&products,vector<int>&prices){this->n=n;this->discount=discount;for(intj=0;j<products.size();++j){d[products[j]]=prices[j];}}doublegetBill(vector<int>product,vector<int>amount){intdis=(++i)%n==0?discount:0;doubleans=0;for(intj=0;j<product.size();++j){intx=d[product[j]]*amount[j];ans+=x-(dis*x)/100.0;}returnans;}private:inti=0;intn;intdiscount;unordered_map<int,int>d;};/** * Your Cashier object will be instantiated and called as such: * Cashier* obj = new Cashier(n, discount, products, prices); * double param_1 = obj->getBill(product,amount); */
typeCashierstruct{iintnintdiscountintdmap[int]int}funcConstructor(nint,discountint,products[]int,prices[]int)Cashier{d:=map[int]int{}fori,product:=rangeproducts{d[product]=prices[i]}returnCashier{0,n,discount,d}}func(this*Cashier)GetBill(product[]int,amount[]int)(ansfloat64){this.i++dis:=0ifthis.i%this.n==0{dis=this.discount}forj,p:=rangeproduct{x:=float64(this.d[p]*amount[j])ans+=x-(float64(dis)*x)/100.0}return}/** * Your Cashier object will be instantiated and called as such: * obj := Constructor(n, discount, products, prices); * param_1 := obj.GetBill(product,amount); */