結果
問題 | No.178 美しいWhitespace (1) |
ユーザー | Tsukasa_Type |
提出日時 | 2018-02-12 00:04:56 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 561 bytes |
コンパイル時間 | 2,505 ms |
コンパイル使用メモリ | 75,296 KB |
実行使用メモリ | 43,976 KB |
最終ジャッジ日時 | 2024-05-01 10:20:21 |
合計ジャッジ時間 | 8,268 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 132 ms
41,728 KB |
testcase_01 | AC | 132 ms
41,616 KB |
testcase_02 | AC | 131 ms
41,268 KB |
testcase_03 | AC | 117 ms
41,464 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 200 ms
43,484 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 206 ms
43,808 KB |
testcase_12 | AC | 208 ms
43,804 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 205 ms
43,364 KB |
testcase_19 | WA | - |
testcase_20 | AC | 206 ms
43,428 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 206 ms
43,460 KB |
testcase_24 | AC | 207 ms
43,408 KB |
ソースコード
import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int n = sc.nextInt(); int[] width = new int[n]; for (int i=0; i<n; i++) { int a = sc.nextInt(); int b = sc.nextInt(); width[i] = a + 4*b; } Arrays.sort(width); int max = width[n-1]; int num = 0; boolean possible = true; for (int i=0; i<n; i++) { int dif = max-width[i]; if (dif%2==0) { num += dif/2; } else {possible = false; break;} } System.out.println(possible==true?num:-1); } }