結果

問題 No.1554 array_and_me
ユーザー kotatsugamekotatsugame
提出日時 2021-06-18 22:08:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 688 bytes
コンパイル時間 871 ms
コンパイル使用メモリ 78,928 KB
実行使用メモリ 5,688 KB
最終ジャッジ日時 2023-09-04 23:15:00
合計ジャッジ時間 4,210 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,380 KB
testcase_01 AC 20 ms
4,380 KB
testcase_02 AC 21 ms
4,376 KB
testcase_03 AC 20 ms
4,380 KB
testcase_04 AC 20 ms
4,380 KB
testcase_05 AC 21 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,292 KB
testcase_12 AC 26 ms
5,356 KB
testcase_13 AC 27 ms
5,332 KB
testcase_14 AC 26 ms
5,448 KB
testcase_15 AC 26 ms
5,356 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,380 KB
testcase_37 AC 39 ms
4,376 KB
testcase_38 AC 39 ms
4,376 KB
testcase_39 AC 40 ms
4,376 KB
testcase_40 AC 39 ms
4,380 KB
testcase_41 AC 22 ms
4,380 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:10:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   10 | main()
      | ^~~~

ソースコード

diff #

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