結果

問題 No.1738 What's in the box?
ユーザー rogi52
提出日時 2022-10-05 01:35:37
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 479 bytes
コンパイル時間 1,864 ms
コンパイル使用メモリ 195,692 KB
最終ジャッジ日時 2025-02-07 21:50:30
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 68 RE * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    // W_i = A_i * w
    // sum A_i = M
    // sum W_i = w * sum A_i = wM
    // A_i = W_i / w = W_i * (M / sum(W))
    ll N,M; cin >> N >> M;
    vector<ll> W(N);
    rep(i,N) cin >> W[i];

    ll sumW = accumulate(W.begin(), W.end(), 0LL);
    rep(i,N) cout << W[i] * M / sumW << " "; cout << endl;
}
0