結果

問題 No.616 へんなソート
ユーザー merom686merom686
提出日時 2017-12-16 01:13:06
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 727 bytes
コンパイル時間 589 ms
コンパイル使用メモリ 73,468 KB
実行使用メモリ 53,868 KB
最終ジャッジ日時 2023-08-21 07:26:55
合計ジャッジ時間 1,913 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
5,548 KB
testcase_03 AC 2 ms
7,600 KB
testcase_04 AC 2 ms
7,456 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
7,472 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
7,564 KB
testcase_09 AC 3 ms
9,544 KB
testcase_10 AC 2 ms
5,556 KB
testcase_11 AC 3 ms
9,548 KB
testcase_12 AC 4 ms
17,696 KB
testcase_13 AC 14 ms
44,360 KB
testcase_14 AC 3 ms
11,524 KB
testcase_15 AC 2 ms
5,448 KB
testcase_16 AC 3 ms
9,544 KB
testcase_17 AC 12 ms
42,416 KB
testcase_18 AC 8 ms
32,076 KB
testcase_19 AC 8 ms
30,004 KB
testcase_20 AC 2 ms
7,508 KB
testcase_21 AC 4 ms
11,728 KB
testcase_22 AC 6 ms
23,840 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 5 ms
22,004 KB
testcase_27 AC 5 ms
21,952 KB
testcase_28 AC 22 ms
53,836 KB
testcase_29 AC 22 ms
53,868 KB
権限があれば一括ダウンロードができます

ソースコード

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[N][K + 1];

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

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

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

    cout << r << endl;

    return 0;
}
0