結果
問題 |
No.602 隠されていたゲーム2
|
ユーザー |
|
提出日時 | 2017-12-18 21:12:54 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 34 ms / 2,000 ms |
コード長 | 833 bytes |
コンパイル時間 | 696 ms |
コンパイル使用メモリ | 64,980 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-16 00:34:14 |
合計ジャッジ時間 | 1,923 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:14:25: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘ll*’ {aka ‘long long int*’} [-Wformat=] 14 | scanf("%d", d + i); | ~^ ~~~~~ | | | | int* ll* {aka long long int*} | %lld main.cpp:14:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | scanf("%d", d + i); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <iostream> #include <algorithm> #include <cstring> #include <cmath> using namespace std; typedef long long int ll; const ll N = 100000; ll d[N],n,cp,src[2][N],lst[2]; int main() { cin >> n; for (int i = 0; i < n; i++) { scanf("%d", d + i); src[d[i] % 2][lst[d[i] % 2]] = d[i]; lst[d[i] % 2]++; } sort(d , d + n); sort(src[0], src[0] + lst[0]); sort(src[1], src[1] + lst[1]); ll 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++) { ll lb = abs(cp - d[i]), ub = (cp + d[i]); ll ni = lower_bound(src[lb % 2], src[lb % 2] + lst[lb % 2], lb) - src[lb % 2]; if (ni<lst[lb%2]&&src[lb%2][ni] <= ub) { cout << 2 << endl; goto end; } } cout << -1 << endl; end:; return 0; }