You are viewing a single comment's thread. Return to all comments →
Hey, can you tell me where am I going wrong? It fails on test case 4 and 5.
This is my solution in Ruby:
n,k =gets.split(' ').map{|x| x.to_i} items = gets.split(' ').map{|x| x.to_i} charge = gets.to_i items_shrd = items - [items[k]] sum = items_shrd.reduce(:+).to_i shr = sum/2 if shr == charge puts 'Bon Appetit' else puts "#{charge-shr}" end
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 →
Hey, can you tell me where am I going wrong? It fails on test case 4 and 5.
This is my solution in Ruby:
n,k =gets.split(' ').map{|x| x.to_i} items = gets.split(' ').map{|x| x.to_i} charge = gets.to_i items_shrd = items - [items[k]] sum = items_shrd.reduce(:+).to_i shr = sum/2 if shr == charge puts 'Bon Appetit' else puts "#{charge-shr}" end