結果

問題 No.602 隠されていたゲーム2
ユーザー knhrknhr
提出日時 2018-10-13 16:44:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 630 bytes
コンパイル時間 680 ms
コンパイル使用メモリ 70,384 KB
実行使用メモリ 10,524 KB
最終ジャッジ日時 2024-04-20 20:06:47
合計ジャッジ時間 5,345 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,524 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 8 ms
5,376 KB
testcase_17 WA -
testcase_18 AC 628 ms
5,376 KB
testcase_19 WA -
testcase_20 AC 42 ms
5,376 KB
testcase_21 AC 32 ms
5,376 KB
testcase_22 WA -
testcase_23 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
const int size=1e5+10;
int n;
int d[size];
int x,y;
int dist;

int main()
{
	cin >> n;
	for(int i=0;i<n;i++)cin >> d[i];
	cin >> x >> y;
	
	dist=abs(x)+abs(y);
	//0
	if(x==0 && y==0)
	{
		cout << 0 << endl;
		return 0;
	}
	
	//1
	for(int i=0;i<n;i++)
	{
		if(dist==d[i])
		{
			cout << 1 << endl;
			return 0;
		}
	}
	
	//2
	sort(d,d+n,greater<int>());
	for(int i=0;i<n;i++)
	{
		if(d[i]>dist)continue;
		for(int j=i;j<n;j++)
		{
			if(d[i]+d[j]==dist)
			{
				cout << 2 << endl;
				return 0;
			}
			if(d[i]+d[j]<dist)break;
		}
	}
	
	cout << -1 << endl;
	return 0;
}
0