solutions(contest): 2065A, 2065B, 2065D

This commit is contained in:
Muhammad Nauman Raza 2025-02-09 16:31:04 +00:00
parent 387cbcb94c
commit 7a02ae5ba6
Signed by: devraza
GPG key ID: 91EAD6081011574B
3 changed files with 51 additions and 0 deletions

View file

@ -0,0 +1,8 @@
t = int(input())
for _ in range(t):
w = input()
w = w[0:len(w)-2]
print(w+"i")

19
solutions/python/2065B.py Normal file
View file

@ -0,0 +1,19 @@
t = int(input())
for _ in range(t):
w = list(input())
adjacent = False
for i in range(1, len(w)):
if w[i] == w[i-1]:
adjacent = True
if len(w) <= 1:
break
if not adjacent:
print(len(w))
continue
print("1")

24
solutions/python/2065D.py Normal file
View file

@ -0,0 +1,24 @@
t = int(input())
for _ in range(t):
n, m = map(int, input().split(' '))
a = []
for _ in range(n):
a.append(list(map(int, input().split(' '))))
a = sorted(a, key=lambda x: sum(x))[::-1]
concat = []
for i in a:
for j in i:
concat.append(j)
total = 0
for idx, i in enumerate(concat):
total += (n*m-idx)*i
print(total)