結果

問題 No.1738 What's in the box?
ユーザー tentententen
提出日時 2021-11-15 09:18:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 1,527 bytes
コンパイル時間 2,068 ms
コンパイル使用メモリ 74,540 KB
実行使用メモリ 51,376 KB
最終ジャッジ日時 2023-08-20 23:02:48
合計ジャッジ時間 7,894 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
49,648 KB
testcase_01 AC 40 ms
49,640 KB
testcase_02 AC 41 ms
49,484 KB
testcase_03 AC 51 ms
47,992 KB
testcase_04 AC 52 ms
49,448 KB
testcase_05 AC 49 ms
49,512 KB
testcase_06 AC 55 ms
47,660 KB
testcase_07 AC 55 ms
50,608 KB
testcase_08 AC 50 ms
49,764 KB
testcase_09 AC 56 ms
50,840 KB
testcase_10 AC 49 ms
49,460 KB
testcase_11 AC 50 ms
49,432 KB
testcase_12 AC 53 ms
49,492 KB
testcase_13 AC 41 ms
51,128 KB
testcase_14 AC 43 ms
49,280 KB
testcase_15 AC 41 ms
49,296 KB
testcase_16 AC 42 ms
49,256 KB
testcase_17 AC 42 ms
49,652 KB
testcase_18 AC 41 ms
49,420 KB
testcase_19 AC 43 ms
49,244 KB
testcase_20 AC 41 ms
49,260 KB
testcase_21 AC 43 ms
47,240 KB
testcase_22 AC 42 ms
49,356 KB
testcase_23 AC 43 ms
49,512 KB
testcase_24 AC 44 ms
49,292 KB
testcase_25 AC 44 ms
49,492 KB
testcase_26 AC 41 ms
49,412 KB
testcase_27 AC 41 ms
49,420 KB
testcase_28 AC 43 ms
49,388 KB
testcase_29 AC 42 ms
49,404 KB
testcase_30 AC 41 ms
49,588 KB
testcase_31 AC 42 ms
49,428 KB
testcase_32 AC 44 ms
49,408 KB
testcase_33 AC 48 ms
49,572 KB
testcase_34 AC 50 ms
50,548 KB
testcase_35 AC 48 ms
49,396 KB
testcase_36 AC 50 ms
49,344 KB
testcase_37 AC 50 ms
49,428 KB
testcase_38 AC 51 ms
49,328 KB
testcase_39 AC 49 ms
49,504 KB
testcase_40 AC 53 ms
50,392 KB
testcase_41 AC 58 ms
50,392 KB
testcase_42 AC 49 ms
47,392 KB
testcase_43 AC 54 ms
50,948 KB
testcase_44 AC 54 ms
50,508 KB
testcase_45 AC 54 ms
48,756 KB
testcase_46 AC 55 ms
49,404 KB
testcase_47 AC 54 ms
49,540 KB
testcase_48 AC 55 ms
50,392 KB
testcase_49 AC 50 ms
49,544 KB
testcase_50 AC 52 ms
49,984 KB
testcase_51 AC 54 ms
49,628 KB
testcase_52 AC 54 ms
51,376 KB
testcase_53 AC 40 ms
49,404 KB
testcase_54 AC 41 ms
49,288 KB
testcase_55 AC 42 ms
49,264 KB
testcase_56 AC 43 ms
49,248 KB
testcase_57 AC 41 ms
49,260 KB
testcase_58 AC 42 ms
49,364 KB
testcase_59 AC 42 ms
49,788 KB
testcase_60 AC 41 ms
49,352 KB
testcase_61 AC 41 ms
49,260 KB
testcase_62 AC 41 ms
49,328 KB
testcase_63 AC 41 ms
49,388 KB
testcase_64 AC 42 ms
49,280 KB
testcase_65 AC 41 ms
49,316 KB
testcase_66 AC 41 ms
49,376 KB
testcase_67 AC 41 ms
49,368 KB
testcase_68 AC 42 ms
49,488 KB
testcase_69 AC 41 ms
49,364 KB
testcase_70 AC 42 ms
49,464 KB
testcase_71 AC 42 ms
49,460 KB
testcase_72 AC 42 ms
49,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        long m = sc.nextInt();
        long total = 0;
        int[] weights = new int[n];
        for (int i = 0; i < n; i++) {
            weights[i] = sc.nextInt();
            total += weights[i];
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            if (i > 0) {
                sb.append(" ");
            }
            if (total == 0) {
                sb.append("0");
            } else {
                sb.append(weights[i] * m / total);
            }
        }
        System.out.println(sb);
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String nextLine() throws Exception {
        return br.readLine();
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0