結果

問題 No.1738 What's in the box?
ユーザー ks2mks2m
提出日時 2021-11-12 21:41:29
言語 Java21
(openjdk 21)
結果
AC  
実行時間 182 ms / 2,000 ms
コード長 843 bytes
コンパイル時間 2,032 ms
コンパイル使用メモリ 78,036 KB
実行使用メモリ 43,468 KB
最終ジャッジ日時 2024-05-04 07:52:08
合計ジャッジ時間 14,197 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
41,420 KB
testcase_01 AC 120 ms
41,540 KB
testcase_02 AC 115 ms
41,196 KB
testcase_03 AC 178 ms
42,500 KB
testcase_04 AC 175 ms
42,904 KB
testcase_05 AC 167 ms
42,456 KB
testcase_06 AC 165 ms
42,600 KB
testcase_07 AC 170 ms
42,572 KB
testcase_08 AC 178 ms
42,792 KB
testcase_09 AC 174 ms
42,780 KB
testcase_10 AC 181 ms
42,848 KB
testcase_11 AC 166 ms
42,952 KB
testcase_12 AC 182 ms
42,468 KB
testcase_13 AC 121 ms
40,168 KB
testcase_14 AC 121 ms
41,700 KB
testcase_15 AC 122 ms
41,316 KB
testcase_16 AC 107 ms
41,268 KB
testcase_17 AC 125 ms
41,764 KB
testcase_18 AC 121 ms
41,620 KB
testcase_19 AC 119 ms
41,316 KB
testcase_20 AC 125 ms
40,384 KB
testcase_21 AC 134 ms
41,428 KB
testcase_22 AC 113 ms
41,260 KB
testcase_23 AC 121 ms
41,140 KB
testcase_24 AC 132 ms
41,704 KB
testcase_25 AC 146 ms
41,896 KB
testcase_26 AC 121 ms
41,816 KB
testcase_27 AC 110 ms
41,656 KB
testcase_28 AC 108 ms
41,484 KB
testcase_29 AC 116 ms
40,532 KB
testcase_30 AC 114 ms
41,168 KB
testcase_31 AC 123 ms
41,928 KB
testcase_32 AC 127 ms
41,516 KB
testcase_33 AC 161 ms
42,000 KB
testcase_34 AC 173 ms
42,968 KB
testcase_35 AC 167 ms
42,000 KB
testcase_36 AC 166 ms
42,584 KB
testcase_37 AC 159 ms
42,308 KB
testcase_38 AC 154 ms
42,616 KB
testcase_39 AC 157 ms
42,140 KB
testcase_40 AC 176 ms
43,468 KB
testcase_41 AC 172 ms
42,452 KB
testcase_42 AC 163 ms
42,764 KB
testcase_43 AC 172 ms
43,136 KB
testcase_44 AC 172 ms
42,656 KB
testcase_45 AC 172 ms
42,708 KB
testcase_46 AC 177 ms
42,620 KB
testcase_47 AC 164 ms
42,200 KB
testcase_48 AC 171 ms
42,668 KB
testcase_49 AC 171 ms
42,280 KB
testcase_50 AC 173 ms
42,660 KB
testcase_51 AC 173 ms
43,224 KB
testcase_52 AC 177 ms
42,468 KB
testcase_53 AC 117 ms
41,540 KB
testcase_54 AC 115 ms
41,536 KB
testcase_55 AC 110 ms
41,552 KB
testcase_56 AC 128 ms
41,576 KB
testcase_57 AC 120 ms
41,272 KB
testcase_58 AC 120 ms
41,532 KB
testcase_59 AC 115 ms
41,560 KB
testcase_60 AC 117 ms
40,016 KB
testcase_61 AC 116 ms
41,404 KB
testcase_62 AC 116 ms
41,500 KB
testcase_63 AC 116 ms
41,316 KB
testcase_64 AC 121 ms
40,160 KB
testcase_65 AC 117 ms
41,524 KB
testcase_66 AC 118 ms
40,992 KB
testcase_67 AC 115 ms
41,572 KB
testcase_68 AC 104 ms
41,660 KB
testcase_69 AC 114 ms
41,308 KB
testcase_70 AC 117 ms
40,152 KB
testcase_71 AC 115 ms
40,284 KB
testcase_72 AC 119 ms
41,164 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