結果

問題 No.616 へんなソート
ユーザー zimphazimpha
提出日時 2017-12-16 19:29:30
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 536 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 32,016 KB
実行使用メモリ 59,068 KB
最終ジャッジ日時 2023-08-21 11:13:35
合計ジャッジ時間 3,187 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
58,972 KB
testcase_01 AC 61 ms
59,020 KB
testcase_02 AC 61 ms
59,020 KB
testcase_03 AC 61 ms
59,032 KB
testcase_04 AC 61 ms
58,888 KB
testcase_05 AC 62 ms
59,020 KB
testcase_06 AC 61 ms
58,972 KB
testcase_07 AC 61 ms
59,044 KB
testcase_08 AC 61 ms
59,024 KB
testcase_09 AC 61 ms
59,048 KB
testcase_10 AC 61 ms
59,020 KB
testcase_11 AC 61 ms
58,916 KB
testcase_12 AC 61 ms
59,044 KB
testcase_13 AC 61 ms
58,916 KB
testcase_14 AC 61 ms
58,916 KB
testcase_15 AC 61 ms
59,040 KB
testcase_16 AC 61 ms
59,016 KB
testcase_17 AC 61 ms
59,048 KB
testcase_18 AC 61 ms
59,024 KB
testcase_19 AC 61 ms
58,920 KB
testcase_20 AC 61 ms
58,916 KB
testcase_21 AC 61 ms
58,976 KB
testcase_22 AC 61 ms
59,068 KB
testcase_23 AC 61 ms
58,884 KB
testcase_24 AC 61 ms
58,976 KB
testcase_25 AC 61 ms
59,032 KB
testcase_26 AC 61 ms
59,048 KB
testcase_27 AC 61 ms
58,916 KB
testcase_28 AC 61 ms
58,972 KB
testcase_29 AC 61 ms
58,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>

constexpr int N = 300 + 10, K = N * (N - 1) / 2;
constexpr int mod = 1e9 + 7;

int dp[N][K];

int main() {
  dp[0][0] = 1;
  for (int i = 1; i < N; ++i) {
    dp[i][0] = 1;
    for (int j = 1; j <= i * (i - 1) / 2; ++j) {
      dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % mod;
      if (j >= i) dp[i][j] = (dp[i][j] - dp[i - 1][j - i] + mod) % mod;
    }
  }
  int n, k;
  scanf("%d%d", &n, &k);
  int ret = 0;
  for (int i = 0; i <= k; ++i) {
    ret = (ret + dp[n][i]) % mod;
  }
  printf("%d\n", ret);
  return 0;
}
0