結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 11 ms
5,376 KB
testcase_17 AC 25 ms
5,376 KB
testcase_18 AC 69 ms
7,552 KB
testcase_19 AC 93 ms
8,576 KB
testcase_20 AC 62 ms
8,448 KB
testcase_21 AC 65 ms
8,576 KB
testcase_22 AC 68 ms
8,576 KB
testcase_23 AC 60 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);
	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