結果
問題 |
No.602 隠されていたゲーム2
|
ユーザー |
![]() |
提出日時 | 2017-12-02 04:12:14 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 616 bytes |
コンパイル時間 | 1,984 ms |
コンパイル使用メモリ | 163,284 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-28 02:38:23 |
合計ジャッジ時間 | 2,187 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 7 |
ソースコード
#include <bits/stdc++.h> using namespace std; int n, x, y, t; long long D; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; vector<long long> d(n); for (int i = 0; i < n; ++i) cin >> d[i]; sort(d.begin(), d.end()); cin >> x >> y; D = abs(x) + abs(y); if (D==0) { cout << 0 << "\n"; return 0; } if (binary_search(d.begin(), d.end(), D)) { cout << 1 << "\n"; return 0; } for (int i = 0; i < n-1; ++i) { if (binary_search(d.begin(), d.end(), abs(D-d[i])) || binary_search(d.begin(), d.end(), D+d[i])) { cout << 2 << "\n"; return 0; } } cout << -1 << "\n"; }