From cf6b235b173e9be51770b40bce1e651cf088fd31 Mon Sep 17 00:00:00 2001 From: Franciszek Malinka Date: Tue, 30 Mar 2021 20:01:08 +0200 Subject: fix --- Semestr 4/aisd/Pracownia 2/gen.py | 24 ---------------- Semestr 4/aisd/Pracownia 2/gen_test.sh | 24 ---------------- Semestr 4/aisd/Pracownia 2/rozw4.cpp | 51 ---------------------------------- 3 files changed, 99 deletions(-) delete mode 100644 Semestr 4/aisd/Pracownia 2/gen.py delete mode 100755 Semestr 4/aisd/Pracownia 2/gen_test.sh delete mode 100644 Semestr 4/aisd/Pracownia 2/rozw4.cpp (limited to 'Semestr 4/aisd/Pracownia 2') diff --git a/Semestr 4/aisd/Pracownia 2/gen.py b/Semestr 4/aisd/Pracownia 2/gen.py deleted file mode 100644 index 13aed55..0000000 --- a/Semestr 4/aisd/Pracownia 2/gen.py +++ /dev/null @@ -1,24 +0,0 @@ -from random import randint, seed -import sys - -if (len(sys.argv) < 4): - print("usage: python3 gen.py seed n sum") - exit() - -seed(sys.argv[1]) - -n, sum = map(int, sys.argv[2:4]) -if n > sum: - print("N musi być mniejsze równe od sum.") - exit() - -t = [1 for i in range(n)] - -for i in range(sum - n): - idx = randint(0, n - 1) - t[idx] += 1 - -print(n) -for i in t: - print(i, end=' ') -print() diff --git a/Semestr 4/aisd/Pracownia 2/gen_test.sh b/Semestr 4/aisd/Pracownia 2/gen_test.sh deleted file mode 100755 index d5bff05..0000000 --- a/Semestr 4/aisd/Pracownia 2/gen_test.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -mkdir -p tests -cp gen.py tests/ -cd tests - -python3 gen.py 1 5 20 > t1.in -python3 gen.py 2 10 100 > t2.in -python3 gen.py 3 20 200 > t3.in -python3 gen.py 4 40 600 > t4.in -python3 gen.py 5 80 5000 > t5.in -python3 gen.py 6 160 10000 > t6.in -python3 gen.py 7 320 10000 > t7.in -python3 gen.py 8 640 20000 > t8.in -python3 gen.py 9 1280 20000 > t9.in -python3 gen.py 10 2000 2000 > t10.in -python3 gen.py 11 2000 20000 > t11.in -python3 gen.py 12 2000 200000 > t12.in -python3 gen.py 13 2000 1000000 > t13.in -python3 gen.py 14 2000 1000000 > t14.in -python3 gen.py 15 2000 1000000 > t15.in - - -rm gen.py diff --git a/Semestr 4/aisd/Pracownia 2/rozw4.cpp b/Semestr 4/aisd/Pracownia 2/rozw4.cpp deleted file mode 100644 index 73ff79a..0000000 --- a/Semestr 4/aisd/Pracownia 2/rozw4.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include -using namespace std; - -const int MAX_SUM = 1e6, MAXN = 2004; -int n; -int dp[2][MAX_SUM + 10], H[MAXN]; - -int main() { - scanf("%d", &n); - for (int i = 0; i < n; ++i) { - scanf("%d", &H[i]); - } - - sort(H, H + n); - - int sum = 0, K = 0; - for (int i = 0; i < n; ++i) { - int h = H[i]; - for (int i = 0; i <= min(sum, MAX_SUM); i++) - dp[K^1][i] = dp[K][i]; - - for (int i = 0; i <= min(sum, MAX_SUM); i++) { - if (i != 0 && dp[K][i] == 0) continue; - - int left = abs(i - h), aux = i-h >= 0 ? 0 : h-i; - if (left <= MAX_SUM) { - dp[K^1][left] = max(dp[K^1][left], dp[K][i] + aux); - } - int right = i + h; - if (right <= MAX_SUM) { - dp[K^1][right] = max(dp[K^1][right], dp[K][i] + h); - } - } - - K ^= 1; - sum += h; - } - if (dp[K][0] != 0) { - printf("TAK\n%d\n", dp[K][0]); - } - else { - int res = 0; - for (int i = 1; i <= MAX_SUM; i++) { - if (dp[K][i] != i && dp[K][i]) { - res = i; - break; - } - } - printf("NIE\n%d\n", res); - } -} \ No newline at end of file -- cgit v1.2.3