結果

問題 No.602 隠されていたゲーム2
ユーザー ryoissyryoissy
提出日時 2017-12-02 00:06:04
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 776 bytes
コンパイル時間 1,489 ms
コンパイル使用メモリ 164,060 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-05 21:27:14
合計ジャッジ時間 2,347 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 1 ms
5,248 KB
testcase_04 AC 1 ms
5,248 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 8 ms
5,376 KB
testcase_18 AC 21 ms
5,376 KB
testcase_19 AC 27 ms
5,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 28 ms
5,376 KB
testcase_23 AC 15 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   13 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
main.cpp:15:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |                 scanf("%d",&d[i]);
      |                 ~~~~~^~~~~~~~~~~~
main.cpp:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |         scanf("%d%d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int d[100001];
int x,y;
vector<int> vi[2];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&d[i]);
		vi[d[i]%2].push_back(d[i]);
	}
	scanf("%d%d",&x,&y);
	if(x==0 && y==0){
		printf("0\n");
		return 0;
	}
	sort(d,d+n);
	sort(vi[0].begin(),vi[0].end());
	sort(vi[1].begin(),vi[1].end());
	for(int i=0;i<n;i++){
		if(d[i]==(abs(x)+abs(y))){
			printf("1\n");
			return 0;
		}
	}
	for(int i=0;i<n;i++){
		int rest=abs(x)+abs(y)-d[i];
		rest=abs(rest);
		int vo=lower_bound(vi[rest%2].begin(),vi[rest%2].end(),rest)-vi[rest%2].begin();
		if(vo!=vi[rest%2].size()){
			printf("2\n");
			return 0;
		}
	}
	printf("-1\n");
	return 0;
}
0