結果
| 問題 | No.602 隠されていたゲーム2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-12-02 00:06:04 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 776 bytes |
| 記録 | |
| コンパイル時間 | 1,548 ms |
| コンパイル使用メモリ | 164,824 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-27 22:49:53 |
| 合計ジャッジ時間 | 2,303 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 WA * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
main.cpp:15:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf("%d",&d[i]);
| ~~~~~^~~~~~~~~~~~
main.cpp:18:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
18 | scanf("%d%d",&x,&y);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n;
int d[100001];
int x,y;
vector<int> vi[2];
int main(void){
scanf("%d",&n);
for(int i=0;i<n;i++){
scanf("%d",&d[i]);
vi[d[i]%2].push_back(d[i]);
}
scanf("%d%d",&x,&y);
if(x==0 && y==0){
printf("0\n");
return 0;
}
sort(d,d+n);
sort(vi[0].begin(),vi[0].end());
sort(vi[1].begin(),vi[1].end());
for(int i=0;i<n;i++){
if(d[i]==(abs(x)+abs(y))){
printf("1\n");
return 0;
}
}
for(int i=0;i<n;i++){
int rest=abs(x)+abs(y)-d[i];
rest=abs(rest);
int vo=lower_bound(vi[rest%2].begin(),vi[rest%2].end(),rest)-vi[rest%2].begin();
if(vo!=vi[rest%2].size()){
printf("2\n");
return 0;
}
}
printf("-1\n");
return 0;
}