Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Last active February 2, 2018 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/c9b684ee986aae1ff528e1ed93960f9f to your computer and use it in GitHub Desktop.
Save whatalnk/c9b684ee986aae1ff528e1ed93960f9f to your computer and use it in GitHub Desktop.
AtCoder ABC #080 C. Shopping Street
# ABC080
# C. Shopping Street
n = gets.chomp.to_i
f_ = []
n.times do
f_ << gets.chomp.split(" ").map(&:to_i)
end
p_ = []
n.times do
p_ << gets.chomp.split(" ").map(&:to_i)
end
profits = []
1.upto((1<<10) - 1) do |b|
prft = 0
n.times do |i|
# Store
c = 0
10.times do |j|
# Time
if (((b >> j) & 1) & f_[i][j]) == 1 then
c += 1
end
end
prft += p_[i][c]
end
profits << prft
end
puts profits.max
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment