結果

問題 No.602 隠されていたゲーム2
ユーザー kotatsugame
提出日時 2020-03-12 03:30:25
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 491 bytes
コンパイル時間 795 ms
コンパイル使用メモリ 75,820 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-11-16 05:04:12
合計ジャッジ時間 2,058 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 1
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);
	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