結果

問題 No.112 ややこしい鶴亀算
ユーザー kotatsugamekotatsugame
提出日時 2016-12-21 22:29:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 471 bytes
コンパイル時間 769 ms
コンパイル使用メモリ 65,996 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-08 10:47:12
合計ジャッジ時間 1,887 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 WA -
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 WA -
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 WA -
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 WA -
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:3:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    3 | main(){
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
main(){
	int n,a[50],t=0,k=0;cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	bool f=true;for(int i=1;i<n;i++)f&=a[i]==a[i-1];
	if(f)
	{
		if(a[0]/2==n)t=n,k=0;
		else t=0,k=n;
	}
	else
	{
		for(int i=2;i<5;i+=2)
		{
			f=false;
			int sum=a[0]+i;
			if(i-2)k++;else t++;
			for(int i=1;i<n;i++)
			{
				if(sum-a[i]==2)t++;
				else if(sum-a[i]==4)k++;
				else f=true;
			}
			if(!f)break;
			else t=k=0;
		}
	}
	cout<<t<<" "<<k<<endl;
}
0