結果

問題 No.616 へんなソート
ユーザー merom686
提出日時 2017-12-16 01:38:48
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 790 bytes
コンパイル時間 828 ms
コンパイル使用メモリ 74,216 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-12-14 16:48:09
合計ジャッジ時間 1,657 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

constexpr int P = 1000000007;

constexpr int N = 300, K = N * (N - 1) / 2;
int dp[K + 1];

int main() {
    int n, k;
    cin >> n >> k;

    dp[0] = 1;
    for (int i = 2; i <= n; i++) {
        int k1 = min(k, i * (i - 1) / 2);
        int64_t t = 0;
        for (int j = 0; j < i; j++) {
            t += dp[k1 - j];
        }
        for (int j = k1; j >= 0; j--) {
            int s = t % P;
            t -= dp[j];
            if (j - i >= 0) t += dp[j - i];
            dp[j] = s;
        }
    }

    int64_t r = 0;
    for (int j = 0; j <= k; j++) {
        r += dp[j];
    }
    r %= P;

    cout << r << endl;

    return 0;
}
0