結果

問題 No.616 へんなソート
ユーザー kurarrrkurarrr
提出日時 2018-02-21 12:19:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 197 ms / 2,000 ms
コード長 1,226 bytes
コンパイル時間 1,271 ms
コンパイル使用メモリ 143,972 KB
実行使用メモリ 217,216 KB
最終ジャッジ日時 2023-10-12 22:36:32
合計ジャッジ時間 3,715 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,336 KB
testcase_01 AC 2 ms
7,452 KB
testcase_02 AC 4 ms
13,660 KB
testcase_03 AC 6 ms
21,760 KB
testcase_04 AC 7 ms
29,980 KB
testcase_05 AC 2 ms
5,360 KB
testcase_06 AC 7 ms
25,944 KB
testcase_07 AC 4 ms
15,636 KB
testcase_08 AC 7 ms
28,040 KB
testcase_09 AC 9 ms
36,124 KB
testcase_10 AC 5 ms
17,960 KB
testcase_11 AC 7 ms
32,228 KB
testcase_12 AC 15 ms
62,856 KB
testcase_13 AC 80 ms
121,848 KB
testcase_14 AC 11 ms
46,480 KB
testcase_15 AC 4 ms
15,600 KB
testcase_16 AC 8 ms
34,192 KB
testcase_17 AC 50 ms
102,368 KB
testcase_18 AC 21 ms
85,188 KB
testcase_19 AC 22 ms
85,260 KB
testcase_20 AC 6 ms
25,864 KB
testcase_21 AC 10 ms
44,604 KB
testcase_22 AC 18 ms
83,704 KB
testcase_23 AC 2 ms
5,576 KB
testcase_24 AC 2 ms
5,532 KB
testcase_25 AC 2 ms
5,440 KB
testcase_26 AC 18 ms
83,244 KB
testcase_27 AC 17 ms
79,088 KB
testcase_28 AC 197 ms
217,208 KB
testcase_29 AC 197 ms
217,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define show_table(n, k, table) rep(i,n){ rep(j,k) cout << table[i][j] << " "; cout << endl;}

template<class T> void chmax(T& a,const T& b){a=max(a,b);}
template<class T> void chmin(T& a,const T& b){a=min(a,b);}

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60;
const int MAX_N = 302;

ll dp[MAX_N][MAX_N*MAX_N/2],sum[MAX_N][MAX_N*MAX_N/2];

int main(){
  int N,K; cin >> N >> K;
  // int a; rep(i,N) cin >> a;
  dp[0][0] = 1;
  rep(j,K+1) sum[0][j] = 1LL;
  REP(i,1,N){
    rep(j,K+1){
      if(min(i,j)<=j-1) dp[i][j] = (sum[i-1][j] - sum[i-1][j-min(i,j)-1] + lmod )%lmod;
      else dp[i][j] = sum[i-1][j];
    }
    sum[i][0] = 1LL;
    REP(j,1,K+1) sum[i][j] = (sum[i][j-1] + dp[i][j])%lmod;
  }
  // show_table(N,K+1,dp);
  cout << sum[N-1][K] << endl;
  return 0;
}
0