結果
問題 |
No.178 美しいWhitespace (1)
|
ユーザー |
![]() |
提出日時 | 2016-05-22 18:32:01 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 199 ms / 2,000 ms |
コード長 | 563 bytes |
コンパイル時間 | 2,186 ms |
コンパイル使用メモリ | 75,444 KB |
実行使用メモリ | 43,536 KB |
最終ジャッジ日時 | 2024-10-06 20:35:55 |
合計ジャッジ時間 | 7,237 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
import java.util.*; class No0178{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); long n = sc.nextInt(); long sp, tb, temp; long cnt = 0; ArrayList<Long> a = new ArrayList<Long>(); 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); } }