結果

問題 No.112 ややこしい鶴亀算
ユーザー prog470
提出日時 2016-09-11 20:40:33
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 857 bytes
コンパイル時間 659 ms
コンパイル使用メモリ 75,216 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-17 03:37:03
合計ジャッジ時間 1,472 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main() {

	int N, turu = 0, kame = 0, a[50];
	cin >> N;
	set <int> s;
	for (int i = 0; i < N; i++) {
		int t;
		cin >> t;
		s.insert(t);
		a[i] = t;
	}

	int n[2] = {}, k = 0;
	set<int>::iterator it = s.begin();
	while (it != s.end()) {
		n[k] = *(it);
		k++;
		it++;
	}
	if (n[0] > n[1]) swap(n[0],n[1]);

	if (s.size() == 1) {
		if (2 * (N-1) == a[0]) cout << N <<" "<<0<< endl;
		else cout << 0 << " " << N << endl;
		return 0;
	}

	//cout << "n0:" << n[0] << " n1:" << n[1] << endl;

	for (int i = 0; i < N; i++) {
		if (a[i] == n[1]) turu++;
		else kame++;
	}

	cout<<turu <<  " " << kame << endl;
	
	return 0;
}
0