結果

問題 No.178 美しいWhitespace (1)
ユーザー darknightdarknight
提出日時 2016-11-17 20:17:23
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 959 bytes
コンパイル時間 3,588 ms
コンパイル使用メモリ 74,532 KB
実行使用メモリ 57,048 KB
最終ジャッジ日時 2023-08-17 08:08:34
合計ジャッジ時間 7,538 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,860 KB
testcase_01 AC 118 ms
55,724 KB
testcase_02 AC 117 ms
55,896 KB
testcase_03 AC 118 ms
55,368 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 177 ms
56,504 KB
testcase_07 WA -
testcase_08 AC 178 ms
56,624 KB
testcase_09 AC 178 ms
56,632 KB
testcase_10 AC 177 ms
56,520 KB
testcase_11 WA -
testcase_12 AC 176 ms
56,636 KB
testcase_13 AC 179 ms
56,920 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 172 ms
54,208 KB
testcase_19 AC 178 ms
56,056 KB
testcase_20 WA -
testcase_21 AC 176 ms
56,476 KB
testcase_22 AC 170 ms
56,204 KB
testcase_23 AC 174 ms
56,712 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;
    boolean huhu = false ;
    
    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++ ){
      
        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 ;
    }
    
    if(  d % 2 == 1 && max % 2 == 0  ) System.out.print( -1 );
    else if(  max % 2 == 1 && d % 2 == 0  ) System.out.print( -1 );
    else         System.out.print(  d );
        System.out.println();
        
	}
}
0