結果

問題 No.112 ややこしい鶴亀算
ユーザー masa
提出日時 2015-04-05 14:43:57
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 668 bytes
コンパイル時間 631 ms
コンパイル使用メモリ 71,968 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-04 02:03:43
合計ジャッジ時間 1,388 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>

using namespace std;

int main() {
	map<int, int> animal;

	int n, foot;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> foot;
		if (animal.count(foot) > 0) {
			animal[foot]++;
		} else {
			animal[foot] = 1;
		}
	}

	int ans[2] = {}; // 鶴・亀の順

	if (animal.size() == 2) {
		for(auto it = animal.begin(); it != animal.end(); it++) {
			int idx = it == animal.begin() ? 1 : 0;
			ans[idx] = it->second;
		}
	} else {
		int idx = foot / (n - 1) == 4 ? 1 : 0;
		ans[idx] = animal[foot];
	}

	cout << ans[0] << " " << ans[1] << endl;
	return 0;
}
0