結果
| 問題 |
No.602 隠されていたゲーム2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-03-12 03:30:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 106 ms / 2,000 ms |
| コード長 | 542 bytes |
| コンパイル時間 | 754 ms |
| コンパイル使用メモリ | 75,420 KB |
| 実行使用メモリ | 8,576 KB |
| 最終ジャッジ日時 | 2024-11-16 05:04:10 |
| 合計ジャッジ時間 | 2,827 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
8 | main()
| ^~~~
ソースコード
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int N;
int D[1<<17];
int x,y;
main()
{
cin>>N;
set<int>S[2];
for(int i=0;i<N;i++)
{
cin>>D[i];
S[D[i]%2].insert(D[i]);
}
cin>>x>>y;
x=abs(x);
y=abs(y);
if(x==0&&y==0)
{
cout<<0<<endl;
return 0;
}
int ans=-1;
for(int i=0;i<N;i++)
{
int L=abs(x+y-D[i]),R=max(abs(D[i]-x)+y,abs(D[i]-y)+x);
set<int>::iterator it=S[L%2].lower_bound(L);
if(it!=S[L%2].end()&&*it<=R)ans=2;
if(L==0)
{
cout<<1<<endl;
return 0;
}
}
cout<<ans<<endl;
}