結果
| 問題 | No.178 美しいWhitespace (1) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-11-03 11:44:41 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 139 ms / 2,000 ms |
| コード長 | 802 bytes |
| 記録 | |
| コンパイル時間 | 3,384 ms |
| コンパイル使用メモリ | 84,828 KB |
| 実行使用メモリ | 47,080 KB |
| 最終ジャッジ日時 | 2026-04-04 05:04:07 |
| 合計ジャッジ時間 | 6,849 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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();
}
}