루미 알고리즘

#1571실버Tug of War

PO 2023 학교 예선코딩출제 Johan Sannemo영어 원문이 문제가 어렵다면 — 배우는 순서 보기

영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)

Problem

During a PE class, the teacher wants to divide all students into two teams to compete in a tug of war. To make the tug of war interesting, the teams should be exactly the same size, as well as exactly equally strong. The teacher has estimated the strength of each student in advance as an integer between 1 and 4. The strength of a team is the sum of the strengths of its members.

Given how many students of each strength are attending the class, can you tell the teacher how to divide the teams? It is guaranteed that the strengths of the students are such that this is always possible.

Input

The first and only line contains the four integers s_1, s_2, s_3, s_4 (0 ≤ s_i ≤ 10^7), where s_i is the number of students with strength i.

Output

Print a line with four integers a_1, a_2, a_3, a_4, where a_i is the number of students with strength i that should be on one of the teams. If there are multiple solutions, you may print any of them.

Scoring

Your solution will be tested on a set of test groups. To earn points for a group, you must pass all test cases in that group.

GroupPointsConstraints
120s_i ≤ 300
220s_i ≤ 2000
320No student has strength 4.
440No additional constraints.

Explanation of Samples

In the first sample, there are four students, one of each strength. Each team should thus have two students. If the students with strengths 1 and 4 are chosen for one team and the students with strengths 2 and 3 are chosen for the other, both teams get the same strength, namely 5.

예제

예제 1

입력
1 1 1 1
출력
0 1 1 0

예제 2

입력
2 4 6 8
출력
0 3 4 3

출처 표기

출처: Programmeringsolympiaden 2023년 학교 예선 · 원문 페이지 · 이용 조건 CC BY-SA · LaTeX 원문을 화면용 글로 옮겼습니다(수식·표의 모양이 다를 수 있습니다). 내용은 고치지 않았습니다.

크리에이티브 커먼즈 저작자표시-동일조건변경허락.

문제 출처: 한국정보올림피아드(KOI) (CC BY-NC-SA 4.0) · International Olympiad in Informatics (IOI) (CC BY) · Centre for Education in Mathematics and Computing (CEMC), University of Waterloo (CC BY-NC 4.0) · Programmeringsolympiaden (CC BY-SA) · CSES Problem Set (Antti Laaksonen) (CC BY-NC-SA 4.0). 루미 알고리즘은 위 단체들과 관계없는 별도의 서비스이며, 자료는 원문 그대로 싣습니다. 문제마다 출처와 이용 조건을 따로 표기합니다.