結果
| 問題 |
No.178 美しいWhitespace (1)
|
| コンテスト | |
| ユーザー |
takeya_okino
|
| 提出日時 | 2017-06-23 06:55:35 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 220 ms / 2,000 ms |
| コード長 | 687 bytes |
| コンパイル時間 | 2,262 ms |
| コンパイル使用メモリ | 74,772 KB |
| 実行使用メモリ | 56,956 KB |
| 最終ジャッジ日時 | 2024-10-02 12:38:57 |
| 合計ジャッジ時間 | 8,077 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int odd = 0;
int even = 0;
long max = 0;
long[] a = new long[N];
long[] b = new long[N];
for(int i = 0; i < N; i++) {
a[i] = sc.nextLong();
b[i] = sc.nextLong();
if(a[i] % 2 == 0) {
even++;
} else {
odd++;
}
max = Math.max(max, a[i] + 4 * b[i]);
}
long ans = 0;
if(even == 0 || odd == 0) {
for(int i = 0; i < N; i++) {
ans += ((max - a[i] - 4 * b[i]) / 2);
}
} else {
ans = -1;
}
System.out.println(ans);
}
}
takeya_okino