summaryrefslogtreecommitdiff
path: root/2010/1a
diff options
context:
space:
mode:
authorYuval Adam <yuv.adm@gmail.com>2011-04-19 12:32:17 +0300
committerYuval Adam <yuv.adm@gmail.com>2011-04-19 12:32:17 +0300
commitcb646fe0d61c5bc24c99de4abe318c76a8d1df2c (patch)
tree3d9bb5497bd836d029ebcf0f2267eb53c24c455c /2010/1a
parentc00e7a90e5cf671a3e66ffea62a5b8b874bfcac8 (diff)
still in progress
Diffstat (limited to '2010/1a')
-rw-r--r--2010/1a/b/1.in5
-rw-r--r--2010/1a/b/b.py23
2 files changed, 21 insertions, 7 deletions
diff --git a/2010/1a/b/1.in b/2010/1a/b/1.in
index e69de29..4e2d3d4 100644
--- a/2010/1a/b/1.in
+++ b/2010/1a/b/1.in
@@ -0,0 +1,5 @@
+2
+6 6 2 3
+1 7 5
+100 1 5 3
+1 50 7 \ No newline at end of file
diff --git a/2010/1a/b/b.py b/2010/1a/b/b.py
index 2ef444c..f22f706 100644
--- a/2010/1a/b/b.py
+++ b/2010/1a/b/b.py
@@ -1,14 +1,23 @@
f = open('1.in', 'r')
o = open('1.out', 'w')
-t = int(f.readline().strip())
+def smooth(a, d, i, m):
+ if len(a) <= 1:
+ return 0
+ if abs(a[0]-a[1]) > m:
+ cd = d + smooth(a[1:], d, i, m)
+ ci = i + smooth(a[1:], d, i, m)
+ cc = c
+ return min(cd, ci, cc) + smooth(a[1:], d, i, m)
+ else:
+ return smooth(a[1:], d, i, m)
-for i in range(t):
- (n, k) = map(int, f.readline().strip().split(' '))
-
- mat = [f.readline().strip() for j in range(n)]
- mat = rotate(gravity(mat))
+T = int(f.readline().strip())
- s = "Case #%d: %s\n" % (i+1, win(mat, k))
+for t in range(T):
+ (d, i, m, _n) = map(int, f.readline().strip().split(' '))
+ A = map(int, f.readline().strip().split(' '))
+ r = smooth(A, d, i, m)
+ s = "Case #%d: %s\n" % (t+1, r)
print s
o.write(s)