about summary refs log tree commit diff
path: root/codechef
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
parent4c5ed94087a691ce47882786aea64f7b5bf3c130 (diff)
downloadcp-d5b549d83292f6573ef3715c17f1d57a41918fb7.tar.gz
Fouracesinarow
Diffstat (limited to 'codechef')
-rwxr-xr-xcodechef/chfar.py4
-rw-r--r--codechef/maxprodu.c38
-rwxr-xr-xcodechef/queue2.py8
-rwxr-xr-xcodechef/snckyear.py4
4 files changed, 54 insertions, 0 deletions
diff --git a/codechef/chfar.py b/codechef/chfar.py
new file mode 100755
index 0000000..1c39e9b
--- /dev/null
+++ b/codechef/chfar.py
@@ -0,0 +1,4 @@
+#!/usr/bin/env python3
+for _ in range(int(input())):
+    n, k = map(int, input().split())
+    print('NO' if input().split().count('1') + k < n else 'YES')
diff --git a/codechef/maxprodu.c b/codechef/maxprodu.c
new file mode 100644
index 0000000..f9ebfff
--- /dev/null
+++ b/codechef/maxprodu.c
@@ -0,0 +1,38 @@
+#include <stdio.h>
+
+int main()
+{
+	long long n, k, si, m, l, r, i, result;
+	int t;
+	scanf("%d\n", &t);
+
+	while (t--) {
+		scanf("%lld %lld\n", &n, &k);
+		si = (k - 1) * k / 2;
+		m = (n - si) / k;
+		if (m < 1) {
+			puts("-1");
+			continue;
+		} else if (m == 1) {
+			puts("0");
+			continue;
+		}
+
+		r = n - si - m * k;
+		l = k - r;
+		result = 1;
+
+		for (i = 0; l--; i++) {
+			result = result * (m + i) % 1000000007;
+			result = result * (m + i - 1) % 1000000007;
+		}
+		for (; r--; i++) {
+			result = result * (m + i) % 1000000007;
+			result = result * (m + i + 1) % 1000000007;
+		}
+
+		printf("%lld\n", result);
+	}
+
+	return 0;
+}
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)
diff --git a/codechef/snckyear.py b/codechef/snckyear.py
new file mode 100755
index 0000000..0d9410a
--- /dev/null
+++ b/codechef/snckyear.py
@@ -0,0 +1,4 @@
+#!/usr/bin/env python
+
+SNCKYEAR = dict.fromkeys((2010, 2015, 2016, 2017, 2019), 'HOSTED')
+for _ in range(int(input())): print(SNCKYEAR.get(int(input()), 'NOT HOSTED'))