結果
問題 |
No.178 美しいWhitespace (1)
|
ユーザー |
![]() |
提出日時 | 2016-05-22 18:30:03 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 566 bytes |
コンパイル時間 | 2,243 ms |
コンパイル使用メモリ | 75,664 KB |
実行使用メモリ | 59,136 KB |
最終ジャッジ日時 | 2024-10-06 20:35:42 |
合計ジャッジ時間 | 8,270 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 WA * 14 |
ソースコード
import java.util.*; class No0178{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int sp, tb, temp; int cnt = 0; ArrayList<Integer> a = new ArrayList<Integer>(); for(int i = 0; i < n; i++){ sp = sc.nextInt(); tb = sc.nextInt() * 4; a.add(sp + tb); } Collections.sort(a); Collections.reverse(a); for(int i = 1; i < n; i++){ temp = a.get(0) - a.get(i); if(temp % 2 != 0){ cnt = -1; break; }else{ cnt = cnt + (temp / 2); } } System.out.println(cnt); } }