結果
| 問題 |
No.112 ややこしい鶴亀算
|
| コンテスト | |
| ユーザー |
kichirb3
|
| 提出日時 | 2018-03-05 21:12:03 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,059 bytes |
| コンパイル時間 | 964 ms |
| コンパイル使用メモリ | 84,548 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-13 15:41:27 |
| 合計ジャッジ時間 | 1,828 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 23 |
ソースコード
// No.112 ややこしい鶴亀算
// https://yukicoder.me/problems/no/112
//
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
int main() {
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
int N;
cin >> N;
unordered_map<int, int> counter;
for (auto i = 0; i < N; ++i) {
int tmp;
cin >> tmp;
counter[tmp]++;
}
vector<pair<int, int>> res;
for (auto c: counter) {
res.push_back(make_pair(c.first, c.second));
}
int animal1_count =res[0].second;
int count1 = res[0].first;
if (res.size() == 1) {
if (count1 + 2 == 2 * animal1_count)
cout << animal1_count << " 0" << endl;
else
cout << "0 " << animal1_count << endl;
} else {
int animal2_count = res[1].second;
int count2 = res[1].first;
if (count1 > count2)
cout << animal1_count << " " << animal2_count << endl;
else
cout << animal2_count << " " << animal1_count << endl;
}
}
kichirb3