結果

問題 No.1554 array_and_me
ユーザー kotatsugamekotatsugame
提出日時 2021-06-18 22:25:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 756 bytes
コンパイル時間 878 ms
コンパイル使用メモリ 81,072 KB
実行使用メモリ 6,300 KB
最終ジャッジ日時 2023-09-04 23:36:39
合計ジャッジ時間 3,813 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,376 KB
testcase_01 AC 20 ms
4,376 KB
testcase_02 AC 20 ms
4,376 KB
testcase_03 AC 20 ms
4,376 KB
testcase_04 AC 19 ms
4,380 KB
testcase_05 AC 20 ms
4,376 KB
testcase_06 AC 46 ms
6,160 KB
testcase_07 AC 46 ms
6,012 KB
testcase_08 AC 46 ms
6,020 KB
testcase_09 AC 49 ms
6,008 KB
testcase_10 AC 46 ms
6,008 KB
testcase_11 AC 26 ms
6,300 KB
testcase_12 AC 26 ms
6,132 KB
testcase_13 AC 26 ms
5,936 KB
testcase_14 AC 26 ms
5,988 KB
testcase_15 AC 27 ms
6,160 KB
testcase_16 AC 7 ms
4,380 KB
testcase_17 AC 7 ms
4,380 KB
testcase_18 AC 8 ms
4,376 KB
testcase_19 AC 7 ms
4,376 KB
testcase_20 AC 7 ms
4,376 KB
testcase_21 AC 35 ms
4,376 KB
testcase_22 AC 36 ms
4,380 KB
testcase_23 AC 36 ms
4,380 KB
testcase_24 AC 36 ms
4,376 KB
testcase_25 AC 36 ms
4,376 KB
testcase_26 AC 41 ms
4,376 KB
testcase_27 AC 41 ms
4,376 KB
testcase_28 AC 41 ms
4,380 KB
testcase_29 AC 40 ms
4,376 KB
testcase_30 AC 41 ms
4,376 KB
testcase_31 AC 41 ms
4,380 KB
testcase_32 AC 41 ms
4,376 KB
testcase_33 AC 42 ms
4,376 KB
testcase_34 AC 41 ms
4,376 KB
testcase_35 AC 41 ms
4,376 KB
testcase_36 AC 39 ms
4,376 KB
testcase_37 AC 39 ms
4,380 KB
testcase_38 AC 40 ms
4,376 KB
testcase_39 AC 39 ms
4,376 KB
testcase_40 AC 40 ms
4,380 KB
testcase_41 AC 23 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:9:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    9 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<queue>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
int T,N,K;
int A[1<<17];
mint inv[1<<17];
main()
{
	cin>>T;
	inv[1]=1;
	for(int i=2;i<1<<17;i++)inv[i]=-(998244353/i)*inv[998244353%i];
	for(;T--;)
	{
		cin>>N>>K;
		int sum=0;
		priority_queue<pair<double,pair<int,int> > >P;
		for(int i=0;i<N;i++)
		{
			cin>>A[i];
			P.push(make_pair(A[i],make_pair(0,A[i])));
			sum+=A[i];
		}
		mint ans=1,invsum=mint(1)/sum;
		for(int i=1;i<=K;i++)
		{
			ans*=i;
			pair<double,pair<int,int> >p=P.top();P.pop();
			p.second.first--;
			p.first=p.second.second/(double)(1-p.second.first);
			P.push(p);
			ans*=inv[-p.second.first];
			ans*=p.second.second*invsum;
		}
		cout<<ans.val()<<endl;
	}
}
0