diff options
Diffstat (limited to '2010/qual/c/c.py')
| -rw-r--r-- | 2010/qual/c/c.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/2010/qual/c/c.py b/2010/qual/c/c.py new file mode 100644 index 0000000..e13369c --- /dev/null +++ b/2010/qual/c/c.py @@ -0,0 +1,34 @@ +f = open('2.in', 'r') +o = open('2.out', 'w') + +t = int(f.readline().strip()) + +def c(l): + while True: + for x in l: + yield x + +for i in xrange(t): + (r, k, n) = map(int, f.readline().strip().split(' ')) + g = map(int, f.readline().strip().split(' ')) + + q = c(g) + + profit = 0 + buf = 0 + for j in xrange(r): + load = 0 + if buf != 0: + next = buf + buf = 0 + else: + next = q.next() + + while load + next <= k: + load += next + next = q.next() + buf = next + profit += load + + s = "Case #%d: %s\n" % (i+1, profit) + o.write(s) |
