結果
問題 | No.178 美しいWhitespace (1) |
ユーザー |
|
提出日時 | 2015-05-27 15:09:51 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 187 ms / 2,000 ms |
コード長 | 553 bytes |
コンパイル時間 | 4,265 ms |
コンパイル使用メモリ | 74,752 KB |
実行使用メモリ | 43,776 KB |
最終ジャッジ日時 | 2024-07-06 11:01:18 |
合計ジャッジ時間 | 8,926 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 21 |
ソースコード
import java.util.*; public class Whitespace{ public static void main(String[] arg){ Scanner sc = new Scanner(System.in); long max=0,sum=0,res = 0; int n = sc.nextInt(); int[] a = new int[n]; int[] b = new int[n]; for(int i = 0;i<n;i++){ a[i] = sc.nextInt(); b[i] = sc.nextInt(); sum = sum + (a[i] % 2); if(a[i] + b[i]*4 >max)max = a[i] + b[i] * 4; } if(sum == n || sum == 0){ for(int i = 0;i<n;i++){ res = res + (max - (a[i] + b[i] *4))/2; } System.out.println(res); }else{ System.out.println(-1); } } }