結果

問題 No.1554 array_and_me
ユーザー kotatsugamekotatsugame
提出日時 2021-06-18 22:15:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 714 bytes
コンパイル時間 799 ms
コンパイル使用メモリ 80,052 KB
実行使用メモリ 5,668 KB
最終ジャッジ日時 2023-09-04 23:20:38
合計ジャッジ時間 3,947 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 20 ms
4,380 KB
testcase_02 AC 20 ms
4,380 KB
testcase_03 AC 20 ms
4,380 KB
testcase_04 AC 20 ms
4,376 KB
testcase_05 AC 20 ms
4,380 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 26 ms
5,300 KB
testcase_12 AC 25 ms
5,444 KB
testcase_13 AC 26 ms
5,512 KB
testcase_14 AC 26 ms
5,440 KB
testcase_15 AC 26 ms
5,504 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 39 ms
4,376 KB
testcase_37 AC 38 ms
4,380 KB
testcase_38 AC 38 ms
4,380 KB
testcase_39 AC 38 ms
4,380 KB
testcase_40 AC 37 ms
4,380 KB
testcase_41 AC 23 ms
4,380 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<int,pair<int,int> > >P;
		for(int i=0;i<N;i++)
		{
			cin>>A[i];
			P.push(make_pair(A[i]*K,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<int,pair<int,int> >p=P.top();P.pop();
			p.first-=sum;
			p.second.first--;
			P.push(p);
			ans*=inv[-p.second.first];
			ans*=p.second.second*invsum;
		}
		cout<<ans.val()<<endl;
	}
}
0