Submission #6638964


Source Code Expand

Copy
N = gets.chomp.to_i
monster = gets.chomp.split(" ").map(&:to_i)
breaves_power = gets.chomp.split(" ").map(&:to_i)

total_beated = 0
for town in (N-1).downto(0) do
  breave_power = breaves_power[town]
  beated1 = 0
  beated2 = 0

  if monster[town+1] > 0
    beated1 = breave_power - monster[town+1]
    if beated1 < 0
      beated1 = breave_power
    else
      beated1 = monster[town+1]
    end
    breave_power -= beated1
    monster[town+1] = monster[town+1] - beated1
  end

  if monster[town] > 0
    beated2 = breave_power - monster[town]
    if beated2 < 0
      beated2 = breave_power
    else
      beated2 = monster[town]
    end
    monster[town] = monster[town] - beated2
  end

  total_beated += beated1 + beated2
end

p total_beated

Submission Info

Submission Time
Task C - City Savers
User rotelstift
Language Ruby (2.3.3)
Score 300
Code Size 782 Byte
Status
Exec Time 135 ms
Memory 17572 KB

Test Cases

Set Name Score / Max Score Test Cases
All 300 / 300 sample_01, sample_02, sample_03, testcase_01, testcase_02, testcase_03, testcase_04, testcase_05, testcase_06, testcase_07, testcase_08, testcase_09, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14
Sample 0 / 0 sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 7 ms 1788 KB
sample_02 7 ms 1788 KB
sample_03 7 ms 3836 KB
testcase_01 81 ms 11124 KB
testcase_02 73 ms 10100 KB
testcase_03 130 ms 17192 KB
testcase_04 126 ms 17176 KB
testcase_05 36 ms 5244 KB
testcase_06 74 ms 9540 KB
testcase_07 121 ms 15636 KB
testcase_08 132 ms 17176 KB
testcase_09 107 ms 13764 KB
testcase_10 132 ms 17176 KB
testcase_11 112 ms 14860 KB
testcase_12 9 ms 1916 KB
testcase_13 135 ms 17572 KB
testcase_14 7 ms 1788 KB