about summary refs log tree commit diff
path: root/codechef/queue2.py
diff options
context:
space:
mode:
authorNguyễn Gia Phong <vn.mcsinyx@gmail.com>2018-10-30 13:22:36 +0700
committerNguyễn Gia Phong <vn.mcsinyx@gmail.com>2018-10-30 13:22:36 +0700
commitd5b549d83292f6573ef3715c17f1d57a41918fb7 (patch)
tree1db9293b28bcba3fdb226306a02c449d35f0590c /codechef/queue2.py
parent4c5ed94087a691ce47882786aea64f7b5bf3c130 (diff)
downloadcp-d5b549d83292f6573ef3715c17f1d57a41918fb7.tar.gz
Fouracesinarow
Diffstat (limited to 'codechef/queue2.py')
-rwxr-xr-xcodechef/queue2.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/codechef/queue2.py b/codechef/queue2.py
new file mode 100755
index 0000000..7f46079
--- /dev/null
+++ b/codechef/queue2.py
@@ -0,0 +1,8 @@
+#!/usr/bin/env python3
+for _ in range(int(input())):
+    n, m, k, l = map(int, input().split())
+    m *= l
+    d = {0: m, k: m - k + n*l}
+    for i, a in enumerate(sorted(map(int, input().split()))):
+        d[a] = m - a + i*l
+    print(min(d.values()) + l)