結果
問題 |
No.1621 Sequence Inversions
|
ユーザー |
|
提出日時 | 2021-07-30 12:38:44 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 597 bytes |
コンパイル時間 | 588 ms |
コンパイル使用メモリ | 71,028 KB |
実行使用メモリ | 7,808 KB |
最終ジャッジ日時 | 2024-09-15 08:13:54 |
合計ジャッジ時間 | 1,891 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 14 WA * 12 |
ソースコード
#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; }