結果

問題 No.616 へんなソート
ユーザー pekempeypekempey
提出日時 2017-12-16 06:56:20
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 610 bytes
コンパイル時間 624 ms
コンパイル使用メモリ 74,424 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2023-08-21 07:55:24
合計ジャッジ時間 6,302 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 7 ms
4,376 KB
testcase_13 AC 862 ms
4,376 KB
testcase_14 AC 5 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 396 ms
4,376 KB
testcase_18 AC 36 ms
4,376 KB
testcase_19 AC 43 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 10 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 TLE -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const long long mod = 1e9 + 7;

void to(long long &x, long long y) {
  x += y;
  if (x >= mod) x -= mod;
}

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

  vector<long long> dp0(K + 1);
  dp0[0] = 1;

  for (int i = 0; i < n; i++) {
    vector<long long> dp1(K + 1);
    for (int j = 0; j <= K; j++) {
      for (int k = 0; k <= i && j + k <= K; k++) {
        to(dp1[j + k], dp0[j]);
      }
    }
    dp0 = dp1;
  }

  long long ans = 0;
  for (int i = 0; i <= K; i++) {
    (ans += dp0[i]) %= mod;
  }

  cout << ans << endl;
}
0