結果

問題 No.178 美しいWhitespace (1)
ユーザー darknightdarknight
提出日時 2016-11-17 20:28:18
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 972 bytes
コンパイル時間 3,002 ms
コンパイル使用メモリ 75,064 KB
実行使用メモリ 56,844 KB
最終ジャッジ日時 2023-08-17 08:08:53
合計ジャッジ時間 8,740 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,644 KB
testcase_01 AC 121 ms
55,996 KB
testcase_02 AC 122 ms
55,388 KB
testcase_03 AC 121 ms
55,772 KB
testcase_04 AC 182 ms
56,412 KB
testcase_05 AC 182 ms
56,368 KB
testcase_06 AC 183 ms
56,468 KB
testcase_07 WA -
testcase_08 AC 181 ms
56,348 KB
testcase_09 AC 181 ms
56,476 KB
testcase_10 AC 184 ms
56,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 179 ms
56,380 KB
testcase_14 AC 182 ms
56,460 KB
testcase_15 AC 179 ms
56,364 KB
testcase_16 AC 180 ms
56,500 KB
testcase_17 AC 179 ms
56,516 KB
testcase_18 WA -
testcase_19 AC 177 ms
56,152 KB
testcase_20 WA -
testcase_21 AC 184 ms
56,268 KB
testcase_22 AC 175 ms
56,376 KB
testcase_23 AC 174 ms
56,612 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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==k) System.out.print( -1 );
    else         System.out.print(  d );
        System.out.println();
        
	}
}
0