summaryrefslogtreecommitdiff
path: root/2010/qual/c/c.py
diff options
context:
space:
mode:
authorYuval Adam <yuv.adm@gmail.com>2011-04-11 00:28:34 +0300
committerYuval Adam <yuv.adm@gmail.com>2011-04-11 00:28:34 +0300
commit2568c9e472f35d902af55b94b2c5dd6e4e4bdd6d (patch)
tree836f94b577804180a7aa27159281f2c791da556a /2010/qual/c/c.py
parent60c20757cfb2bb4743db0e349337049006edd341 (diff)
buggy version for c
Diffstat (limited to '2010/qual/c/c.py')
-rw-r--r--2010/qual/c/c.py34
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)