結果

問題 No.1554 array_and_me
ユーザー 👑 NachiaNachia
提出日時 2021-06-18 22:08:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 897 bytes
コンパイル時間 954 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 6,184 KB
最終ジャッジ日時 2023-09-04 23:15:18
合計ジャッジ時間 4,500 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 29 ms
4,380 KB
testcase_02 AC 29 ms
4,376 KB
testcase_03 AC 29 ms
4,376 KB
testcase_04 AC 29 ms
4,376 KB
testcase_05 AC 29 ms
4,380 KB
testcase_06 AC 59 ms
5,988 KB
testcase_07 AC 58 ms
5,976 KB
testcase_08 AC 58 ms
6,000 KB
testcase_09 AC 60 ms
6,036 KB
testcase_10 AC 60 ms
5,864 KB
testcase_11 AC 15 ms
5,940 KB
testcase_12 AC 14 ms
6,184 KB
testcase_13 AC 14 ms
5,940 KB
testcase_14 AC 14 ms
5,852 KB
testcase_15 AC 14 ms
5,868 KB
testcase_16 AC 32 ms
4,380 KB
testcase_17 AC 32 ms
4,380 KB
testcase_18 AC 32 ms
4,380 KB
testcase_19 AC 32 ms
4,376 KB
testcase_20 AC 32 ms
4,376 KB
testcase_21 AC 45 ms
4,380 KB
testcase_22 AC 45 ms
4,376 KB
testcase_23 AC 45 ms
4,376 KB
testcase_24 AC 45 ms
4,380 KB
testcase_25 AC 45 ms
4,380 KB
testcase_26 AC 51 ms
4,376 KB
testcase_27 AC 51 ms
4,380 KB
testcase_28 AC 50 ms
4,380 KB
testcase_29 AC 51 ms
4,376 KB
testcase_30 AC 50 ms
4,376 KB
testcase_31 AC 50 ms
4,380 KB
testcase_32 AC 50 ms
4,376 KB
testcase_33 AC 50 ms
4,376 KB
testcase_34 AC 50 ms
4,376 KB
testcase_35 AC 51 ms
4,376 KB
testcase_36 AC 48 ms
4,376 KB
testcase_37 AC 49 ms
4,376 KB
testcase_38 AC 48 ms
4,380 KB
testcase_39 AC 49 ms
4,380 KB
testcase_40 AC 48 ms
4,380 KB
testcase_41 AC 40 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <queue>
#include <atcoder/modint>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

using mll = atcoder::static_modint<998244353>;

struct Frac{
  ll b=0, d=1;
};

bool operator<(Frac l, Frac r){ return l.b * r.d < l.d * r.b; }

void testcase(){
  int N,K; cin >> N >> K;
  vector<ll> A(N); rep(i,N) cin >> A[i];
  ll sumA = 0;
  rep(i,N) sumA += A[i];
  mll ans = 1;
  priority_queue<Frac> Q;
  rep(i,N) Q.push(Frac{ A[i],1 });
  rep(t,K){
    Frac q = Q.top(); Q.pop();
    ans = ans * (t+1) * q.b / q.d / sumA;
    Q.push(Frac{ q.b,q.d+1 });
  }
  cout << ans.val() << "\n";
}


int main(){
  int T; cin >> T;
  while(T--) testcase();
  return 0;
}

struct ios_do_not_sync{
  ios_do_not_sync(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} ios_do_not_sync_inst;
0