結果

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

ソースコード

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 = animal[foot] / (n - 1) == 4 ? 1 : 0;
		ans[idx] = animal[foot];
	}

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