結果
| 問題 | 
                            No.602 隠されていたゲーム2
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2017-12-18 15:45:11 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 640 bytes | 
| コンパイル時間 | 711 ms | 
| コンパイル使用メモリ | 64,732 KB | 
| 実行使用メモリ | 13,768 KB | 
| 最終ジャッジ日時 | 2024-12-15 23:51:44 | 
| 合計ジャッジ時間 | 4,633 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 19 WA * 1 TLE * 1 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:41: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |         for (int i = 0; i < n; i++)scanf("%d", d + i);
      |                                    ~~~~~^~~~~~~~~~~~~
            
            ソースコード
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N = 100000;
int d[N],n,cp;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)scanf("%d", d + i);
	sort(d , d + n);
	int x, y; cin >> x >> y;
	cp = abs(x) + abs(y);
	if (cp == 0) { cout << 0 << endl; goto end; }
	if (find(d, d + n, cp) - d < n) { cout << 1 << endl; goto end; }
	for (int i = 0; i < n; i++) {
		int lb = abs(cp - d[i]), ub = (cp + d[i]);
		for (int j = lower_bound(d, d + n, lb) - d; j<n&&d[j] <= ub; j++) {
			if (d[j] % 2 == ub % 2) { cout << 2 << endl; goto end; }
		}
	}
	cout << -1 << endl;
end:;
	return 0;
}