結果
| 問題 | 
                            No.178 美しいWhitespace (1)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             darknight
                         | 
                    
| 提出日時 | 2016-11-17 19:50:23 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 852 bytes | 
| コンパイル時間 | 2,145 ms | 
| コンパイル使用メモリ | 77,412 KB | 
| 実行使用メモリ | 42,820 KB | 
| 最終ジャッジ日時 | 2024-11-26 03:08:48 | 
| 合計ジャッジ時間 | 7,047 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 3 WA * 18 | 
ソースコード
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
 
	Scanner sc  = new Scanner(System.in);
        
    int cnt = 0;
    boolean huhu = false ;
    
    int N = Integer.parseInt(sc.next());
    
    int[] a = new int[N]; 
    int[] b = new int[N]; 
    int[] sum = new int[N+1]; 
    while(true){
        a[cnt] = Integer.parseInt(sc.next());
        b[cnt] = Integer.parseInt(sc.next());
        cnt++;
        if(cnt==N)break;
    }
    
    for( int i = 0; i < N ; i++ ){
        sum[i] = a[i] +  ( 4 * b[i] );
    }
    
    Arrays.sort(sum);
    int max = sum[N];
    int d = 0;
    
    for( int i = 1; i < N ; i++ ){
         d += ( max - sum[i] ) / 2 ;
    }
    
    if( ( max - sum[1] ) % 2 == 1  ) System.out.print( -1 );
    else         System.out.print(  d );
        System.out.println();
	}
        
}
            
            
            
        
            
darknight