icpc probs
This commit is contained in:
parent
4c531b965f
commit
69d48861b1
17 changed files with 448 additions and 2 deletions
0
kattis/10-9-2024/1/input.txt
Normal file
0
kattis/10-9-2024/1/input.txt
Normal file
15
kattis/10-9-2024/1/script.py
Normal file
15
kattis/10-9-2024/1/script.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
n, a = list(map(int, input().split()))
|
||||
|
||||
es = list(map(int, input().split()))
|
||||
|
||||
es.sort()
|
||||
|
||||
won = 0
|
||||
|
||||
for e in es:
|
||||
if a <= e:
|
||||
break
|
||||
won += 1
|
||||
a -= (e + 1)
|
||||
|
||||
print(won)
|
||||
2
kattis/10-9-2024/3/input.txt
Normal file
2
kattis/10-9-2024/3/input.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
10 15
|
||||
10 11 12 13 14 15
|
||||
44
kattis/10-9-2024/3/script.py
Normal file
44
kattis/10-9-2024/3/script.py
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
from math import gcd
|
||||
|
||||
a, b = map(int, input().split())
|
||||
max_num = float('-inf')
|
||||
|
||||
transcript = input().split()
|
||||
|
||||
fizzs = []
|
||||
buzzs = []
|
||||
|
||||
for i, token in enumerate(transcript):
|
||||
num = a + i
|
||||
|
||||
max_num = max(max_num, num)
|
||||
|
||||
if token.startswith("Fizz") or token.endswith("Fizz"):
|
||||
fizzs.append(num)
|
||||
if token.startswith("Buzz") or token.endswith("Buzz"):
|
||||
buzzs.append(num)
|
||||
|
||||
|
||||
def gcf(nums: list[int]) -> int:
|
||||
if not nums:
|
||||
return ''
|
||||
if len(nums) == 1:
|
||||
return nums[0]
|
||||
|
||||
x, y = nums[0], nums[1]
|
||||
ans = gcd(x, y)
|
||||
|
||||
for i in range(2, len(nums)):
|
||||
ans = gcd(ans, nums[i])
|
||||
|
||||
return ans
|
||||
|
||||
|
||||
a, b = gcf(fizzs), gcf(buzzs)
|
||||
|
||||
if a == '':
|
||||
a = max_num + 1
|
||||
if b == '':
|
||||
b = max_num + 1
|
||||
|
||||
print(a, b)
|
||||
54
kattis/10-9-2024/4/script.py
Normal file
54
kattis/10-9-2024/4/script.py
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
N = int(input())
|
||||
|
||||
matrix: list[list[int]] = []
|
||||
for i in range(N):
|
||||
matrix[i] = list(map(int, list(input())))
|
||||
|
||||
row_map = [0] * N
|
||||
col_map = [0] * N
|
||||
|
||||
ones_above = 0
|
||||
ones_above_row = [0] * N
|
||||
|
||||
for i, row in enumerate(matrix):
|
||||
ones_above_row[i] = ones_above
|
||||
total = 0
|
||||
for cell in row:
|
||||
total += cell
|
||||
row_map[i] = total
|
||||
ones_above += row_map[i]
|
||||
|
||||
ones_left = 0
|
||||
ones_left_col = [0] * N
|
||||
|
||||
for col in range(N):
|
||||
total = 0
|
||||
for row in range(N):
|
||||
total += matrix[row][col]
|
||||
ones_left_col[col] = ones_left
|
||||
col_map[col] = total
|
||||
ones_left += col_map[col]
|
||||
|
||||
found_valid_row = False
|
||||
for i in range(N):
|
||||
flips_remain = row_map[i]
|
||||
total_ones = ones_above_row[-1] - row_map[i] + row_map[-1]
|
||||
if total_ones <= flips_remain:
|
||||
row_flag = True
|
||||
break
|
||||
|
||||
found_valid_col = False
|
||||
for i in range(N):
|
||||
flips_remain = col_map[i]
|
||||
total_ones = ones_left_col[-1] - col_map[i] + col_map[-1]
|
||||
if total_ones <= flips_remain:
|
||||
found_valid_col = True
|
||||
break
|
||||
|
||||
if found_valid_row:
|
||||
if found_valid_col:
|
||||
print("+")
|
||||
else:
|
||||
print("-")
|
||||
else:
|
||||
print("-")
|
||||
3
kattis/10-9-2024/contest.md
Normal file
3
kattis/10-9-2024/contest.md
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# contest 1
|
||||
|
||||
https://open.kattis.com/contests/asurii
|
||||
Loading…
Add table
Add a link
Reference in a new issue