diff --git a/storage/jungol/py/completed/1077.py b/storage/jungol/py/completed/1077.py new file mode 100644 index 0000000..56b04b8 --- /dev/null +++ b/storage/jungol/py/completed/1077.py @@ -0,0 +1,15 @@ +import sys + +input = sys.stdin.readline + +if __name__ == "__main__": + n, w = map(int, input().split()) + jewelries = [tuple(map(int, input().split())) for _ in range(n)] + + dp = [0] * (w + 1) + + for weight, price in jewelries: + for j in range(weight, w + 1): + dp[j] = max(dp[j], dp[j - weight] + price) + + print(dp[w]) \ No newline at end of file diff --git a/storage/jungol/py/completed/14020.py b/storage/jungol/py/completed/14020.py new file mode 100644 index 0000000..6f15ee8 --- /dev/null +++ b/storage/jungol/py/completed/14020.py @@ -0,0 +1,36 @@ +import sys + +input = sys.stdin.readline + + +if __name__ == "__main__": + n, q = map(int, input().split()) + prices = list(map(int, input().split())) + + if n <= 3: + s = sum(prices) + r1 = (100 - q) * s // 100 + r2 = s - min(prices) + print(int(min(r1, r2))) + elif q == 0: + prices.sort() + s = 0 + while len(prices) >= 3: + s += prices.pop() + s += prices.pop() + prices.pop() + s += sum(prices) + print(s) + elif q >= 34: + print(sum(prices) * (100 - q) // 100) + else: + prices.sort(reverse=True) + dp = [0] * (n + 1) + + for i in range(1, n + 1): + dp[i] = dp[i - 1] + prices[i - 1] * (100 - q) // 100 + g = 0 + if i >= 3: + g = prices[i - 3] + prices[i - 2] + dp[i] = min(dp[i], dp[i - 3] + g) + print(dp[n]) diff --git a/storage/jungol/py/completed/3135.py b/storage/jungol/py/completed/3135.py new file mode 100644 index 0000000..4d41971 --- /dev/null +++ b/storage/jungol/py/completed/3135.py @@ -0,0 +1,16 @@ +import sys + +input = sys.stdin.readline + +if __name__ == "__main__": + n = int(input()) + arr = list(map(int, input().split())) + cum = [0] * (n + 1) + + for i in range(1, n + 1): + cum[i] = cum[i - 1] + arr[i - 1] + + q = int(input()) + for _ in range(q): + s, e = map(int, input().split()) + print(cum[e] - cum[s - 1]) diff --git a/storage/jungol/rs/completed/3006.rs b/storage/jungol/rs/completed/3006.rs new file mode 100644 index 0000000..c9cf153 --- /dev/null +++ b/storage/jungol/rs/completed/3006.rs @@ -0,0 +1,28 @@ +use std::io::{read_to_string, stdin}; + +fn main() { + let temp = read_to_string(stdin()).unwrap(); + let mut iter = temp + .split_ascii_whitespace() + .map(|x| x.parse::().unwrap()); + + let (n, m) = (iter.next().unwrap(), iter.next().unwrap()); + + let mut cumf = 2 % m; + let (mut f1, mut f2) = (1 % m, 1 % m); + + if n == 1 { + println!("{}", f1); + } else if n == 2 { + println!("{}", cumf); + } else { + for _ in 3..=n { + let newf = (f2 + f1) % m; + cumf += newf; + cumf %= m; + f1 = f2; + f2 = newf; + } + println!("{}", cumf); + } +}