結果
| 問題 |
No.602 隠されていたゲーム2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-17 16:49:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,446 bytes |
| コンパイル時間 | 1,002 ms |
| コンパイル使用メモリ | 67,344 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-15 22:37:09 |
| 合計ジャッジ時間 | 1,903 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 WA * 2 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’:
main.cpp:16:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
16 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
main.cpp:20:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | scanf("%d", &d[i]);
| ~~~~~^~~~~~~~~~~~~
main.cpp:23:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
23 | scanf("%d %d", &x, &y);
| ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
#define PRINT(x) { std::cout << #x << ": " << x << std::endl; }
//#define PRINT(x)
int main(int argc, char *argv[])
{
int n;
scanf("%d", &n);
vector<int> d(n);
for (int i = 0; i < n; ++i)
{
scanf("%d", &d[i]);
}
int x, y;
scanf("%d %d", &x, &y);
if (x == 0 && y == 0)
{
puts("0");
return 0;
}
int D = abs(x) + abs(y);
vector<int>::iterator it = find(d.begin(),
d.end(),
D);
if (it != d.end())
{
puts("1");
return 0;
}
int dmin = 2147483647, dmax = -2147483648;
for (int i = 0; i < n; ++i)
{
if (D - d[i] > 0)
{
dmin = std::min(D - d[i], dmin);
dmax = std::max(dmin + 2 * d[i], dmax);
}
else
{
dmin = std::min(d[i] - D, dmin);
dmax = std::max(dmin + 2 * D, dmax);
}
}
bool ok = false;
for (int j = 0; j < n; ++j)
{
int dd = d[j] - dmin;
if (dd < 0) continue;
if (dd % 2 == 1) continue;
if (dmax - d[j] < 0) continue;
ok = true;
break;
}
if (ok)
{
puts("2");
}
else
{
puts("-1");
}
return 0;
}