結果
| 問題 |
No.602 隠されていたゲーム2
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2017-12-02 22:58:50 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,188 bytes |
| コンパイル時間 | 2,609 ms |
| コンパイル使用メモリ | 108,032 KB |
| 実行使用メモリ | 29,056 KB |
| 最終ジャッジ日時 | 2024-11-28 03:56:14 |
| 合計ジャッジ時間 | 4,543 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 WA * 6 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class TEST{
static void Main(){
Sol mySol =new Sol();
mySol.Solve();
}
}
class Sol{
public void Solve(){
Array.Sort(D);
if(CheckZero()){
Console.WriteLine(0);
return;
}
if(CheckOne()){
Console.WriteLine(1);
return;
}
if(CheckTwo()){
Console.WriteLine(2);
return;
}
Console.WriteLine(-1);
}
bool CheckZero(){
return X == 0 && Y == 0;
}
bool CheckOne(){
for(int i=0;i<N;i++){
if(X + Y == D[i]) return true;
}
return false;
}
bool CheckTwo(){
long[] TT = new long[]{X - Y, X + Y};
if(TT.Max() <= 2 * D[N-1]) return true;
for(int i=0;i<N-1;i++){
long r0 = D[i];
if(D[i+1] - r0 > TT[0]) continue;
if(D[N-1] + r0 < TT[0]) continue;
int l,r,ll,rr;
l = i + 1;
r = N;
while(r - l > 1){
int c = (r + l) / 2;
if(D[c] - r0 <= TT[0]){
l = c;
} else {
r = c;
}
}
rr = l;
l = i + 1;
r = N;
while(r - l > 1){
int c = (r + l) / 2;
if(D[c] + r0 < TT[0]){
l = c;
} else {
r = c;
}
}
ll = r;
if(D[ll] - r0 <= TT[1] && TT[1] <= D[rr] + r0) return true;
}
return false;
}
int N;
long[] D;
long X,Y;
public Sol(){
N = ri();
D = rla();
var d = rla();
X = d[0]; Y = d[1];
if(X < 0) X *= -1;
if(Y < 0) Y *= -1;
if(Y > X) { Swap(ref X, ref Y);}
}
void Swap<T>(ref T x, ref T y){
T tmp = x; x = y; y = tmp;
}
static String rs(){return Console.ReadLine();}
static int ri(){return int.Parse(Console.ReadLine());}
static long rl(){return long.Parse(Console.ReadLine());}
static double rd(){return double.Parse(Console.ReadLine());}
static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}
kuuso1