結果

問題 No.1738 What's in the box?
ユーザー ks2mks2m
提出日時 2021-11-12 21:41:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 190 ms / 2,000 ms
コード長 843 bytes
コンパイル時間 2,493 ms
コンパイル使用メモリ 74,060 KB
実行使用メモリ 58,352 KB
最終ジャッジ日時 2023-08-17 00:32:21
合計ジャッジ時間 16,824 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,788 KB
testcase_01 AC 121 ms
55,892 KB
testcase_02 AC 121 ms
55,792 KB
testcase_03 AC 180 ms
55,944 KB
testcase_04 AC 184 ms
56,000 KB
testcase_05 AC 184 ms
58,352 KB
testcase_06 AC 184 ms
56,364 KB
testcase_07 AC 188 ms
56,388 KB
testcase_08 AC 184 ms
56,240 KB
testcase_09 AC 188 ms
56,012 KB
testcase_10 AC 185 ms
56,164 KB
testcase_11 AC 183 ms
56,304 KB
testcase_12 AC 186 ms
55,744 KB
testcase_13 AC 126 ms
55,796 KB
testcase_14 AC 126 ms
55,748 KB
testcase_15 AC 124 ms
55,736 KB
testcase_16 AC 125 ms
55,948 KB
testcase_17 AC 127 ms
56,056 KB
testcase_18 AC 122 ms
55,596 KB
testcase_19 AC 125 ms
56,024 KB
testcase_20 AC 124 ms
55,780 KB
testcase_21 AC 136 ms
56,508 KB
testcase_22 AC 127 ms
55,824 KB
testcase_23 AC 126 ms
56,036 KB
testcase_24 AC 161 ms
56,116 KB
testcase_25 AC 158 ms
55,996 KB
testcase_26 AC 123 ms
55,844 KB
testcase_27 AC 123 ms
55,892 KB
testcase_28 AC 125 ms
55,776 KB
testcase_29 AC 125 ms
55,900 KB
testcase_30 AC 122 ms
55,888 KB
testcase_31 AC 136 ms
55,736 KB
testcase_32 AC 137 ms
55,884 KB
testcase_33 AC 181 ms
56,724 KB
testcase_34 AC 186 ms
56,100 KB
testcase_35 AC 181 ms
56,412 KB
testcase_36 AC 183 ms
56,040 KB
testcase_37 AC 181 ms
55,936 KB
testcase_38 AC 175 ms
56,280 KB
testcase_39 AC 170 ms
56,060 KB
testcase_40 AC 190 ms
56,348 KB
testcase_41 AC 188 ms
56,604 KB
testcase_42 AC 172 ms
56,536 KB
testcase_43 AC 183 ms
56,512 KB
testcase_44 AC 182 ms
56,000 KB
testcase_45 AC 185 ms
56,664 KB
testcase_46 AC 176 ms
56,352 KB
testcase_47 AC 184 ms
56,608 KB
testcase_48 AC 186 ms
56,248 KB
testcase_49 AC 184 ms
56,748 KB
testcase_50 AC 188 ms
56,276 KB
testcase_51 AC 185 ms
57,076 KB
testcase_52 AC 184 ms
55,952 KB
testcase_53 AC 121 ms
56,040 KB
testcase_54 AC 122 ms
56,040 KB
testcase_55 AC 121 ms
55,816 KB
testcase_56 AC 130 ms
55,592 KB
testcase_57 AC 123 ms
55,916 KB
testcase_58 AC 122 ms
55,824 KB
testcase_59 AC 124 ms
55,788 KB
testcase_60 AC 122 ms
55,788 KB
testcase_61 AC 121 ms
55,600 KB
testcase_62 AC 122 ms
56,056 KB
testcase_63 AC 121 ms
56,164 KB
testcase_64 AC 121 ms
55,880 KB
testcase_65 AC 122 ms
56,296 KB
testcase_66 AC 121 ms
56,012 KB
testcase_67 AC 119 ms
55,888 KB
testcase_68 AC 122 ms
55,724 KB
testcase_69 AC 121 ms
55,924 KB
testcase_70 AC 120 ms
55,824 KB
testcase_71 AC 119 ms
55,560 KB
testcase_72 AC 121 ms
55,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long m = sc.nextInt();
		int[] w = new int[n];
		for (int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
		}
		sc.close();

		if (m == 0) {
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < n; i++) {
				sb.append(0).append(' ');
			}
			sb.deleteCharAt(sb.length() - 1);
			System.out.println(sb.toString());
		} else {
			long sum = 0;
			for (int i = 0; i < n; i++) {
				sum += w[i];
			}

			// x = sum / m
			// w[i]m / sum
			StringBuilder sb = new StringBuilder();
			for (int i = 0; i < n; i++) {
				long ans = w[i] * m / sum;
				sb.append(ans).append(' ');
			}
			sb.deleteCharAt(sb.length() - 1);
			System.out.println(sb.toString());
		}
	}
}
0