結果
問題 | No.178 美しいWhitespace (1) |
ユーザー |
![]() |
提出日時 | 2016-02-24 12:41:20 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 186 ms / 2,000 ms |
コード長 | 752 bytes |
コンパイル時間 | 3,543 ms |
コンパイル使用メモリ | 74,620 KB |
実行使用メモリ | 54,476 KB |
最終ジャッジ日時 | 2024-09-22 13:17:47 |
合計ジャッジ時間 | 8,883 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
import java.util.Scanner; public class No178 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); long max = 0, ans = 0; int N; N = Integer.parseInt(sc.next()); long[] a = new long[N]; long[] b = new long[N]; for (int i = 0; i < N; i++) { a[i] = Long.parseLong(sc.next()); b[i] = Long.parseLong(sc.next()); max = Math.max(max, a[i] + 4 * b[i]); } for (int i = 0; i < N; i++) { long po = max - (a[i] + 4 * b[i]); if(po % 2 == 1){ System.out.println(-1); return; } ans += po / 2; } System.out.println(ans); } }