結果
| 問題 |
No.112 ややこしい鶴亀算
|
| コンテスト | |
| ユーザー |
kichirb3
|
| 提出日時 | 2018-03-05 21:00:53 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 5,000 ms |
| コード長 | 1,112 bytes |
| コンパイル時間 | 424 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-09-13 15:26:54 |
| 合計ジャッジ時間 | 1,766 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 23 |
ソースコード
# -*- 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:])
kichirb3