結果

問題 No.1621 Sequence Inversions
ユーザー chocoruskchocorusk
提出日時 2021-07-22 21:51:52
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 600 ms / 3,000 ms
コード長 1,576 bytes
コンパイル時間 6,151 ms
コンパイル使用メモリ 195,156 KB
実行使用メモリ 225,044 KB
最終ジャッジ日時 2023-09-24 16:35:13
合計ジャッジ時間 10,278 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
224,944 KB
testcase_01 AC 90 ms
225,028 KB
testcase_02 AC 88 ms
224,860 KB
testcase_03 AC 87 ms
224,744 KB
testcase_04 AC 93 ms
224,792 KB
testcase_05 AC 87 ms
224,744 KB
testcase_06 AC 86 ms
224,868 KB
testcase_07 AC 86 ms
224,752 KB
testcase_08 AC 224 ms
224,808 KB
testcase_09 AC 126 ms
224,880 KB
testcase_10 AC 136 ms
224,796 KB
testcase_11 AC 243 ms
224,756 KB
testcase_12 AC 538 ms
225,044 KB
testcase_13 AC 600 ms
224,748 KB
testcase_14 AC 157 ms
224,948 KB
testcase_15 AC 99 ms
224,892 KB
testcase_16 AC 124 ms
224,752 KB
testcase_17 AC 166 ms
224,816 KB
testcase_18 AC 122 ms
224,796 KB
testcase_19 AC 87 ms
224,752 KB
testcase_20 AC 102 ms
224,756 KB
testcase_21 AC 183 ms
224,828 KB
testcase_22 AC 109 ms
224,752 KB
testcase_23 AC 220 ms
224,752 KB
testcase_24 AC 87 ms
224,820 KB
testcase_25 AC 87 ms
224,808 KB
testcase_26 AC 87 ms
224,752 KB
testcase_27 AC 87 ms
224,740 KB
testcase_28 AC 88 ms
224,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint998244353;
mint dp[101][101][5555];
int main()
{
    int n, k;
    cin>>n>>k;
    int a[101];
    map<int, int> mp;
    for(int i=0; i<n; i++){
        cin>>a[i];
        mp[a[i]]++;
    }
    sort(a, a+n);
    dp[0][0][0]=1;
    for(int i=1; i<n; i++){
        if(a[i-1]!=a[i]){
            for(int j=0; j<=k; j++){
                mint s=0;
                for(int pr=0; pr<i; pr++){
                    s+=dp[i-1][pr][j];
                }
                for(int l=0; l<=i; l++){
                    dp[i][l][j+i-l]+=s;
                }
            }
            continue;
        }
        for(int pr=0; pr<i; pr++){
            for(int j=0; j<=k; j++){
                if(dp[i-1][pr][j]==0) continue;
                for(int l=pr+1; l<=i; l++){
                    dp[i][l][j+i-l]+=dp[i-1][pr][j];
                }
            }
        }
    }
    mint ans=0;
    for(int i=0; i<=n; i++) ans+=dp[n-1][i][k];
    cout<<ans.val()<<endl;
    return 0;
}
0