結果
| 問題 | No.602 隠されていたゲーム2 |
| コンテスト | |
| ユーザー |
creep04
|
| 提出日時 | 2017-12-02 03:21:05 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 497 bytes |
| 記録 | |
| コンパイル時間 | 1,878 ms |
| コンパイル使用メモリ | 160,216 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-28 02:33:04 |
| 合計ジャッジ時間 | 2,329 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | scanf("%lld", &n);
| ~~~~~^~~~~~~~~~~~
main.cpp:8:42: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | for (int i = 0; i < n; ++i) scanf("%lld", &d[i]);
| ~~~~~^~~~~~~~~~~~~~~
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%lld %lld", &x, &y);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
long long n, x, y, a, t, r=3;
int main() {
scanf("%lld", &n);
long long d[n];
for (int i = 0; i < n; ++i) scanf("%lld", &d[i]);
sort(d, d+n);
scanf("%lld %lld", &x, &y);
a = abs(x) + abs(y);
if (a==0) {
printf("0\n");
return 0;
}
for (int i = 0; i < n; ++i) {
if (d[i]==a) r = 1;
else if (binary_search(d+i+1, d+n, abs(a-d[i])) || binary_search(d+i+1, d+n, a+d[i]))
if (r==3) r = 2;
}
if (r==3) r = -1;
printf("%lld\n", r);
}
creep04