Предмет: Информатика, автор: konstantinvyazovik16

Міс М живе на планеті Бітакуляндії та вирішила зробити переїзд із країни Держпродія до країни Тоболяндія. Поки що вона вирішила перемістити чотири найважливіших речей. Для переміщення вона вирішила використовувати дві коробки, куди покладе усі речі. Відомо, що i-а річ важить w i ​ кілограмів та знаходиться в t i ​ -й коробці. Їй потрібно буде переміщати коробки по одній, тому вона дуже хотіла б, щоб коробки не були заважкими. Тобто щоб максимально можлива вага коробки була мінімальною. Через те, що в неї не так багато часу, вона може лише перемістити одну річ з однієї коробки в іншу. Допоможіть їй полегшити переїзд та знайдіть, яку річ потрібно перекласти! Вхідні дані Перший рядок містить чотири цілі числа w 1 ​ , w 2 ​ , w 3 ​ , w 4 ​ (1≤w i ​ ≤10 6 ) — ваги кожної з чотирьох речей. Другий рядок містить чотири цілі числа t 1 ​ , t 2 ​ , t 3 ​ , t 4 ​ (1≤t i ​ ≤2) — номери коробок, у яких лежать відповідні речі. Вихідні дані Виведіть одне ціле число p (1≤p≤4) — номер речі, яку потрібно перемістити в іншу коробку. Якщо є декілька правильних відповідей, то можете вивести будь-яку з них. Якщо оптимально нічого не змінювати, то виведіть одне ціле число «-1».

код на пайтон 3.8

Ответы

Автор ответа: centerm
0

Ответ:

Це на 71%, пайтон

Объяснение:

# Зчитуємо вхідні дані

weights = list(map(int, input().split()))

boxes = list(map(int, input().split()))

# Визначаємо ваги коробок

box_weights = [0, 0]

for i in range(4):

  box_weights[boxes[i] - 1] += weights[i]

# Шукаємо оптимальне переміщення

max_weight = max(box_weights)

item_to_move = -1

for i in range(4):

  from_box = boxes[i] - 1

  to_box = 1 - from_box

  current_weight = box_weights[from_box] - weights[i] + box_weights[to_box]

  if current_weight < max_weight:

      max_weight = current_weight

      item_to_move = i + 1

# Виводимо результат

print(item_to_move)

Похожие вопросы
Предмет: Английский язык, автор: gggtygg35
WRITING Form 7
Variant 1
I. Choose and circle the correct modal verb.
1. Pupils must/mustn’t obey the teacher.
2. You have to/needn’t take off your hats when you enter your
classroom.
3. Pupils needn’t/need use the Internet at theirIT lessons.
II. Complete the sentences ( too or enough).
1. I left the coffee for a minute to cool because it was _________ hot to
drink.
2. He wasn’t strong __________ to lift that heavy box.
3. It is ___________ difficult to do for a little child.
III. Choose and circle the correct indefinite pronoun.
1. Everybody/Anybody enjoyed themselves at Kate’s party.
2. Let’s have something/everything to eat before the lesson.
3. Is nobody/anybody here?
IV. Complete the sentences ( a little or a few).
1. I’ve got __________money. Let’s have coffee.
2. She can speak__________Spanish.
3. I write _________ letters every week.
V. Write about the householding chores in your family
- the way you divide the householding chores in your family
- who does the main part of the housework
- what chores you like/don’t like doing
__________________________________________________________
__________________________________________________________
__________________________________________________________
__________________________________________________________
__________________________________________________________
__________________________________________________________
__________________________________________________________
__________________________________________________________
__________________________________________________________
__________________________________________________________
__________________________________________________________
__________________________________________________________

WRITING Form 7
Variant 1І
I. Choose and circle the correct modal verb.
1. Mobile phones needn’t/must be turned off during regular school
hours.
2. Pupils have to/mustn’t use someone else’s book.
3. Students needn’t/mustn’t have dangerous objects at school.
II. Complete the sentences ( too or enough).
1. I didn’t buy the car because it was _________expensive.
2. He didn’t work hard ________to pass the exam.
3. The photograph didn’t come out because it was _________dark.
III. Choose and circle the correct indefinite pronoun.
1. Everybody/everywhere likes holidays.
2. He says he knows nothing/anything about her.
3. There is anything/something I ant to tell you.
IV. Complete the sentences ( a little or a few).
1. We had ________rain last week.
2. I’ve got ________stamps.
3. They made________ mistakes, but it was OK.
V. Write about your favourite dish
- its name
- its ingredients
- how to cook it
- when you eat it
__________________________________________________________
__________________________________________________________
__________________________________________________________
__________________________________________________________
__________________________________________________________
__________________________________________________________
__________________________________________________________
__________________________________________________________
__________________________________________________________
__________________________________________________________
__________________________________________________________
__________________________________________________________
СРОЧНО ДАЮ 50 БАЛОВ
Предмет: Математика, автор: miroslav18udm
Предмет: Физика, автор: timaushanaorzumurado