7 585
مشترکین
-524 ساعت
-367 روز
-6130 روز
آرشیو پست ها
def bubble_sort(a1, a2):
n = len(a1)
for i in range(n):
swapped = False
for j in range(0, n - i - 1):
if a1[j] > a1[j + 1]:
a1[j], a1[j + 1] = a1[j + 1], a1[j]
a2[j], a2[j + 1] = a2[j + 1], a2[j]
swapped = True
if not swapped:
break
return a2
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
result = bubble_sort(a1, a2)
print(*result)
Bubble sort ✅
from collections import defaultdict
def calculate_manhattan_distance(point1, point2):
return abs(point1[0] - point2[0]) + abs(point1[1] - point2[1])
def find_min_distance_traveled(passenger_coordinates, vehicle_coordinates):
assigned_vehicles = set()
total_travel_distance = 0
for passenger_name in sorted(passenger_coordinates):
min_distance = float('inf')
assigned_vehicle = ''
for vehicle_id in sorted(vehicle_coordinates):
if vehicle_id not in assigned_vehicles:
distance = calculate_manhattan_distance(passenger_coordinates[passenger_name], vehicle_coordinates[vehicle_id])
if distance < min_distance or (distance == min_distance and vehicle_id < assigned_vehicle):
min_distance = distance
assigned_vehicle = vehicle_id
total_travel_distance += min_distance
assigned_vehicles.add(assigned_vehicle)
return total_travel_distance
if name == "main":
num_passengers, num_vehicles = map(int, input().split())
passengers = {}
vehicles = {}
for _ in range(num_passengers):
passenger_name, x, y = input().split()
passengers[passenger_name] = (int(x), int(y))
for _ in range(num_vehicles):
vehicle_id, x, y = input().split()
vehicles[vehicle_id] = (int(x), int(y))
result = find_min_distance_traveled(passengers, vehicles)
print(result, end="")
Solo Rider done ✅
100% working
TCS Codevita ✅
def minVehicles(weights, limit):
weights.sort() # Sort the weights in ascending order
left, right = 0, len(weights) - 1
vehicles = 0
while left <= right:
if weights[left] + weights[right] <= limit:
left += 1
right -= 1
vehicles += 1
return vehicles
# Python 3 compatibility
try:
# Python 3
raw_input = input
except NameError:
# Python 2
pass
weights = list(map(int, raw_input().split()))
limit = int(raw_input())
result = minVehicles(weights, limit)
# Output the result without extra spaces or newline characters
print(result, end="")
Warehouse code ✅
100% working code
TCS codevita
TCS CODEVITA SOLUTIONS GROUP:
https://t.me/cod_solutions
اکنون در دسترس! پژوهش تلگرام ۲۰۲۵ — مهمترین بینشهای سال 
