結果
問題 | No.178 美しいWhitespace (1) |
ユーザー |
![]() |
提出日時 | 2018-02-12 00:05:29 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 204 ms / 2,000 ms |
コード長 | 562 bytes |
コンパイル時間 | 2,121 ms |
コンパイル使用メモリ | 74,504 KB |
実行使用メモリ | 56,960 KB |
最終ジャッジ日時 | 2024-11-21 13:56:08 |
合計ジャッジ時間 | 7,936 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
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]; long 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); } }