結果
| 問題 |
No.178 美しいWhitespace (1)
|
| コンテスト | |
| ユーザー |
Tsukasa_Type
|
| 提出日時 | 2018-02-12 00:04:56 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 561 bytes |
| コンパイル時間 | 2,444 ms |
| コンパイル使用メモリ | 75,164 KB |
| 実行使用メモリ | 43,964 KB |
| 最終ジャッジ日時 | 2024-11-21 13:53:32 |
| 合計ジャッジ時間 | 8,057 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 WA * 14 |
ソースコード
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];
int 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);
}
}
Tsukasa_Type