結果
問題 |
No.602 隠されていたゲーム2
|
ユーザー |
![]() |
提出日時 | 2017-12-03 16:39:11 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,477 bytes |
コンパイル時間 | 2,298 ms |
コンパイル使用メモリ | 82,044 KB |
実行使用メモリ | 61,140 KB |
最終ジャッジ日時 | 2024-11-28 14:17:58 |
合計ジャッジ時間 | 8,477 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 6 WA * 15 |
ソースコード
import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; import java.util.Scanner; import java.util.TreeSet; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int n = sc.nextInt(); long[] array = new long[n]; long odd_max = 0, even_max = 0; for(int i = 0; i < n; i++){ array[i] = sc.nextLong(); if(array[i] % 2 == 0){ even_max = Math.max(even_max, array[i]); }else{ odd_max = Math.max(odd_max, array[i]); } } final long x = sc.nextLong(); final long y = sc.nextLong(); final long d = Math.abs(x) + Math.abs(y); if(d == 0){ System.out.println(0); return; } if(odd_max == 0){ if(d % 2 == 1){ System.out.println(1); return; }else if(d <= even_max){ System.out.println(1); return; }else if(d <= even_max * 2){ System.out.println(2); return; }else{ System.out.println(-1); return; } }else{ final long d_even_max = Math.max(odd_max * 2, even_max * 2); final long d_odd_max = odd_max + even_max; if(d % 2 == 0 && d <= even_max){ System.out.println(1); return; }else if(d % 2 == 1 && d <= odd_max){ System.out.println(1); return; }else if(d % 2 == 0 && d <= d_even_max){ System.out.println(2); return; }else if(d % 2 == 0 && d <= d_odd_max){ System.out.println(2); return; }else{ System.out.println(-1); return; } } } }