結果
| 問題 |
No.178 美しいWhitespace (1)
|
| コンテスト | |
| ユーザー |
ちよちゃん
|
| 提出日時 | 2016-06-07 00:12:51 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,022 bytes |
| コンパイル時間 | 4,666 ms |
| コンパイル使用メモリ | 79,544 KB |
| 実行使用メモリ | 57,240 KB |
| 最終ジャッジ日時 | 2024-10-08 16:53:20 |
| 合計ジャッジ時間 | 8,987 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 6 WA * 15 |
ソースコード
package yukicoder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Yuki178 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int a[] = new int[n];
int b[] = new int[n];
boolean a_flg = false;
boolean b_flg = false;
ArrayList<Integer> array = new ArrayList<Integer>();
for (int i = 0; i < n ; i++ ) {
a[i] = scan.nextInt();
b[i] = scan.nextInt();
}
scan.close();
int ans = 0;
for (int i = 0; i < n ; i++ ) {
ans = a[i] + 4 * b[i];
if(ans != 0) {
if(ans % 2 == 0 ){
a_flg = true;
}else if(ans % 3 == 0 ){
b_flg = true;
}
}
array.add(ans);
}
Collections.sort(array);
int max = Collections.max(array);
ans = 0;
for(Integer num : array){
ans += ((max - num) / 2);
}
if( a_flg == b_flg == true){
System.out.println(-1);
}else {
System.out.println(ans);
}
}
}
ちよちゃん