結果

問題 No.1738 What's in the box?
ユーザー ks2m
提出日時 2021-11-12 21:40:08
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 613 bytes
コンパイル時間 3,768 ms
コンパイル使用メモリ 75,216 KB
実行使用メモリ 54,052 KB
最終ジャッジ日時 2024-11-25 17:34:05
合計ジャッジ時間 16,872 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 68 RE * 2
権限があれば一括ダウンロードができます

ソースコード

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();

		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