結果

問題 No.602 隠されていたゲーム2
ユーザー kotatsugamekotatsugame
提出日時 2020-03-12 03:30:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 542 bytes
コンパイル時間 630 ms
コンパイル使用メモリ 75,460 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-04-27 22:20:05
合計ジャッジ時間 2,283 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int N;
int D[1<<17];
int x,y;
main()
{
	cin>>N;
	set<int>S[2];
	for(int i=0;i<N;i++)
	{
		cin>>D[i];
		S[D[i]%2].insert(D[i]);
	}
	cin>>x>>y;
	x=abs(x);
	y=abs(y);
	if(x==0&&y==0)
	{
		cout<<0<<endl;
		return 0;
	}
	int ans=-1;
	for(int i=0;i<N;i++)
	{
		int L=abs(x+y-D[i]),R=max(abs(D[i]-x)+y,abs(D[i]-y)+x);
		set<int>::iterator it=S[L%2].lower_bound(L);
		if(it!=S[L%2].end()&&*it<=R)ans=2;
		if(L==0)
		{
			cout<<1<<endl;
			return 0;
		}
	}
	cout<<ans<<endl;
}
0