結果
問題 |
No.178 美しいWhitespace (1)
|
ユーザー |
|
提出日時 | 2015-11-03 11:44:41 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 210 ms / 2,000 ms |
コード長 | 802 bytes |
コンパイル時間 | 3,538 ms |
コンパイル使用メモリ | 74,800 KB |
実行使用メモリ | 53,040 KB |
最終ジャッジ日時 | 2024-09-13 12:02:56 |
合計ジャッジ時間 | 9,297 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
import java.util.Scanner; public class Main_yukicoder178 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] s = new long[n]; long max = 0; boolean flag = true; for (int i = 0; i < n; i++) { int a = sc.nextInt(); int b = sc.nextInt(); s[i] = (long)a + b * 4; max = Math.max(max, s[i]); if (i > 0 && s[i] % 2 != s[i - 1] % 2) { flag = false; } } if (flag) { long ret = 0; for (int i = 0; i < n; i++) { ret += (max - s[i]) / 2; } System.out.println(ret); } else { System.out.println("-1"); } sc.close(); } }