結果
| 問題 | 
                            No.178 美しいWhitespace (1)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             darknight
                         | 
                    
| 提出日時 | 2016-11-17 20:33:59 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 978 bytes | 
| コンパイル時間 | 2,238 ms | 
| コンパイル使用メモリ | 77,816 KB | 
| 実行使用メモリ | 42,668 KB | 
| 最終ジャッジ日時 | 2024-11-26 03:09:43 | 
| 合計ジャッジ時間 | 6,603 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 4 | 
| other | WA * 21 | 
ソースコード
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
 
	Scanner sc  = new Scanner(System.in);
        
    int cnt = 0;
    int g = 0, k = 0 ;
    
    int N = Integer.parseInt(sc.next());
    
    Long[] a = new Long[N]; 
    Long[] b = new Long[N]; 
    Long[] sum = new Long[N+1]; 
    while(true){
        a[cnt] = Long.parseLong(sc.next());
        b[cnt] = Long.parseLong(sc.next());
        cnt++;
        if(cnt==N)break;
    }
    
    sum[0] = (long)0;
    for( int i = 0; i < N ; i++ ){
      
        if(a[i]%2==1) g++;
        else k++;
        sum[i+1] = a[i] + ( 4 * b[i] );
    }
    
    Arrays.sort( sum );
    Long max = sum[N];
    long d = 0;
    
    for( int i = 1; i < N ; i++ ){
         d += ( max - sum[i] ) / 2 ;
    }
    
    
     System.out.println(g);
     System.out.println(k);
    
    if(g>0 && k>0) System.out.print( -1 );
    else         System.out.print(  d );
        System.out.println();
        
	}
}
            
            
            
        
            
darknight