Submission #12679948


Source Code Expand

Copy
n, m, q = gets.split.map(&:to_i)
abcds = q.times.map { gets.split.map(&:to_i) }
ans = 0

arrs = [*1..m].repeated_combination(n)

arrs.each do |arr|
  sum = 0

  sum = abcds.inject(0) do |r, (a, b, c, d)|
    r + (arr[b - 1] - arr[a - 1] == c ? d : 0)
  end

  ans = sum if sum >= ans
end

puts ans

Submission Info

Submission Time
Task C - Many Requirements
User cheezenaan
Language Ruby (2.7.1)
Score 300
Code Size 315 Byte
Status
Exec Time 534 ms
Memory 14324 KB

Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 00-sample-00, 00-sample-01, 00-sample-02
All 300 / 300 00-sample-00, 00-sample-01, 00-sample-02, 01-handmade-03, 01-handmade-04, 01-handmade-05, 01-handmade-06, 02-random-07, 02-random-08, 02-random-09, 02-random-10, 02-random-11, 02-random-12, 02-random-13, 02-random-14
Case Name Status Exec Time Memory
00-sample-00 50 ms 14128 KB
00-sample-01 53 ms 14060 KB
00-sample-02 84 ms 14184 KB
01-handmade-03 53 ms 14324 KB
01-handmade-04 534 ms 14152 KB
01-handmade-05 479 ms 14128 KB
01-handmade-06 51 ms 14192 KB
02-random-07 53 ms 14068 KB
02-random-08 53 ms 13960 KB
02-random-09 52 ms 14180 KB
02-random-10 51 ms 14196 KB
02-random-11 55 ms 14252 KB
02-random-12 56 ms 14124 KB
02-random-13 96 ms 14164 KB
02-random-14 531 ms 14252 KB