結果

問題 No.1621 Sequence Inversions
ユーザー the-xinthe-xin
提出日時 2021-07-30 12:38:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 597 bytes
コンパイル時間 641 ms
コンパイル使用メモリ 69,292 KB
実行使用メモリ 7,768 KB
最終ジャッジ日時 2023-10-13 11:13:42
合計ジャッジ時間 2,508 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 4 ms
5,172 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 5 ms
4,348 KB
testcase_16 AC 13 ms
4,956 KB
testcase_17 AC 24 ms
6,032 KB
testcase_18 AC 12 ms
4,836 KB
testcase_19 AC 2 ms
4,352 KB
testcase_20 AC 7 ms
4,416 KB
testcase_21 AC 28 ms
6,232 KB
testcase_22 AC 8 ms
4,456 KB
testcase_23 AC 32 ms
6,760 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,352 KB
testcase_26 WA -
testcase_27 AC 1 ms
4,352 KB
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
const int N = 100+10,mod = 998244353;
typedef long long LL;
LL f[N][N*N];
int a[N];
int last[N];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);
	int now=1;
	for(int i=1;i<=n;i++){
		while(a[now]!=a[i])now++;
		last[i]=i-(i-now);//前面相同的数的个数 
	}
	f[1][0]=1;
	for(int i=2;i<=n;i++){
		for(int j=last[i];j>=1;j--){//增加 
			for(int k=i-j;k<=m;k++){
				f[i][k]+=f[i-1][k-(i-j)];
				f[i][k]%=mod;
			}
		}
	}
	cout<<f[n][m];
	return 0;
}
0