結果

問題 No.178 美しいWhitespace (1)
ユーザー darknightdarknight
提出日時 2016-11-17 19:37:13
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 860 bytes
コンパイル時間 1,901 ms
コンパイル使用メモリ 74,928 KB
実行使用メモリ 59,040 KB
最終ジャッジ日時 2023-08-17 08:06:48
合計ジャッジ時間 6,832 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 108 ms
55,988 KB
testcase_02 AC 107 ms
55,836 KB
testcase_03 AC 110 ms
56,020 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 166 ms
56,288 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 164 ms
56,092 KB
testcase_12 AC 166 ms
56,556 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 163 ms
56,604 KB
testcase_19 WA -
testcase_20 AC 164 ms
56,472 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 162 ms
57,944 KB
testcase_24 AC 162 ms
56,536 KB
権限があれば一括ダウンロードができます

ソースコード

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());
    
    int[] a = new int[N]; 
    int[] b = new int[N]; 
    int[] sum = new int[N+1]; 

    while(true){
        a[cnt] = Integer.parseInt(sc.next());
        if(a[cnt]%2==1) huhu = true; 
        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(huhu) System.out.print(-1);
    else    System.out.print( d);
        System.out.println();
	}
        
}
0