結果
| 問題 |
No.602 隠されていたゲーム2
|
| コンテスト | |
| ユーザー |
tsutaj
|
| 提出日時 | 2017-12-02 02:38:55 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 874 bytes |
| コンパイル時間 | 459 ms |
| コンパイル使用メモリ | 45,524 KB |
| 実行使用メモリ | 6,816 KB |
| 最終ジャッジ日時 | 2024-11-28 02:30:24 |
| 合計ジャッジ時間 | 1,384 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 WA * 5 |
ソースコード
#include <cstdio>
#include <cstdlib>
#include <algorithm>
int N;
int d[100010];
int main() {
scanf("%d", &N);
for(int i=0; i<N; i++) scanf("%d", &d[i]);
int x, y; scanf("%d%d", &x, &y);
// ans = 0
if(x == 0 && y == 0) printf("0\n");
else {
// ans = 1
int mh = abs(x) + abs(y);
for(int i=0; i<N; i++) {
if(mh == d[i]) {
printf("1\n");
return 0;
}
}
// ans = 2
std::sort(d, d+N);
int ma = std::max(abs(x), abs(y));
for(int i=0; i<N; i++) {
int flr = abs(ma - d[i]);
int idx = std::lower_bound(d, d+i, flr) - d;
if(idx < i && d[idx] >= flr) {
printf("2\n");
return 0;
}
}
// no solution
printf("-1\n");
}
return 0;
}
tsutaj