Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created March 21, 2018 04:25
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/bd399e4656c86d00aa48511e6bb445c9 to your computer and use it in GitHub Desktop.
Save whatalnk/bd399e4656c86d00aa48511e6bb445c9 to your computer and use it in GitHub Desktop.
COLOCON 2018 B. すぬけそだて――チュートリアル――
n, x = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp
tt = []
n.times do
tt << gets.chomp.to_i
end
ans = 0
n.times do |i|
if s[i] == '0' then
ans += tt[i]
else
ans += [tt[i], x].min
end
end
puts ans
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment