結果

問題 No.112 ややこしい鶴亀算
ユーザー kichirb3kichirb3
提出日時 2018-03-05 21:00:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 20 ms / 5,000 ms
コード長 1,112 bytes
コンパイル時間 90 ms
コンパイル使用メモリ 10,768 KB
実行使用メモリ 8,660 KB
最終ジャッジ日時 2023-10-11 16:49:35
合計ジャッジ時間 1,677 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,660 KB
testcase_01 AC 19 ms
8,460 KB
testcase_02 AC 20 ms
8,460 KB
testcase_03 AC 20 ms
8,492 KB
testcase_04 AC 20 ms
8,496 KB
testcase_05 AC 18 ms
8,504 KB
testcase_06 AC 18 ms
8,656 KB
testcase_07 AC 18 ms
8,508 KB
testcase_08 AC 18 ms
8,648 KB
testcase_09 AC 19 ms
8,592 KB
testcase_10 AC 18 ms
8,524 KB
testcase_11 AC 19 ms
8,632 KB
testcase_12 AC 19 ms
8,652 KB
testcase_13 AC 19 ms
8,596 KB
testcase_14 AC 19 ms
8,528 KB
testcase_15 AC 19 ms
8,544 KB
testcase_16 AC 18 ms
8,548 KB
testcase_17 AC 18 ms
8,488 KB
testcase_18 AC 18 ms
8,656 KB
testcase_19 AC 18 ms
8,532 KB
testcase_20 AC 19 ms
8,652 KB
testcase_21 AC 18 ms
8,652 KB
testcase_22 AC 18 ms
8,528 KB
testcase_23 AC 18 ms
8,568 KB
testcase_24 AC 19 ms
8,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
"""
No.112 ややこしい鶴亀算
https://yukicoder.me/problems/no/112

"""
import sys
from sys import stdin
from collections import Counter
input = stdin.readline


def main(args):
    N = int(input())
    numbers = [int(x) for x in input().split()]
    c = Counter(numbers).most_common() #  カウント数を集計する

    animal1_count = c[0][1]
    count1 = c[0][0]
    if len(c) == 1:             #  カウント数が1種類しか無い場合、鶴か亀のどちらかしかいない
        if count1 + 2 == 2 * animal1_count: #  自分の足の数を2にして辻褄が合うようであれば鶴のみ、それ以外なら亀のみ
            print(animal1_count, 0)
        else:
            print(0, animal1_count)
    else:
        animal2_count = c[1][1]
        count2 = c[1][0]
        if count1 > count2:     #  2種類のカウントがある場合、鶴のカウントの方が2だけ大きくなる
            print(animal1_count, animal2_count)
        else:
            print(animal2_count, animal1_count)


if __name__ == '__main__':
    main(sys.argv[1:])
0