問題一覧 > 通常問題

No.112 Confusing Crane-and-Turtle Problem

レベル : / AI推定難易度 : 214 / 実行時間制限 : 1ケース 5.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 557
作問者 : sugim48 / テスター : kroton
お気に入りにしたユーザー ProblemId : 253 / 自分の提出
問題文最終更新日: 2026-06-25 10:44:40
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 70 (順位表) の他の問題:

Problem Statement

There are $N$ animals.
The animals are numbered from $1$ to $N$.
Each animal is either a crane or a turtle.
As you know, a crane has $2$ legs and a turtle has $4$ legs.

One day, the animals decided to study crane-and-turtle arithmetic.
To begin, each animal individually counted "the total number of legs of everyone."
However, being careless, all of the animals forgot to count their own legs.

Your task is to determine the number of cranes and the number of turtles from these counts.

Input

$N$
$a_1$ $a_2$ $\ldots$ $a_N$

Line $1$ gives the number of animals $N(2\leq N\leq50)$.
Line $2$ gives, separated by spaces, the total number of legs $a_i$ counted by the $i$-th animal.
$a_i$ are values that satisfy the problem's constraints.

Output

Output the number of cranes and the number of turtles, in this order, separated by a space.
It is guaranteed that exactly one solution exists.
Print a newline at the end.

Sample

Sample 1
Input
2
2 4
Output
1 1

Animal number $1$ is a turtle, and animal number $2$ is a crane.

Sample 2
Input
3
4 4 4
Output
3 0

All $3$ animals are cranes.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。