結果

問題 No.616 へんなソート
ユーザー koyoprokoyopro
提出日時 2020-01-23 23:37:44
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 368 ms / 2,000 ms
コード長 1,370 bytes
コンパイル時間 2,193 ms
コンパイル使用メモリ 144,728 KB
実行使用メモリ 151,552 KB
最終ジャッジ日時 2023-09-29 01:59:19
合計ジャッジ時間 4,827 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
5,428 KB
testcase_02 AC 3 ms
11,780 KB
testcase_03 AC 5 ms
19,760 KB
testcase_04 AC 7 ms
28,040 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 6 ms
23,936 KB
testcase_07 AC 4 ms
13,940 KB
testcase_08 AC 7 ms
26,028 KB
testcase_09 AC 8 ms
32,208 KB
testcase_10 AC 5 ms
15,700 KB
testcase_11 AC 7 ms
30,216 KB
testcase_12 AC 16 ms
60,904 KB
testcase_13 AC 132 ms
102,620 KB
testcase_14 AC 12 ms
42,324 KB
testcase_15 AC 4 ms
13,604 KB
testcase_16 AC 8 ms
32,128 KB
testcase_17 AC 73 ms
92,436 KB
testcase_18 AC 24 ms
84,216 KB
testcase_19 AC 26 ms
84,268 KB
testcase_20 AC 6 ms
23,896 KB
testcase_21 AC 10 ms
40,308 KB
testcase_22 AC 20 ms
83,612 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 17 ms
83,528 KB
testcase_27 AC 17 ms
77,100 KB
testcase_28 AC 368 ms
149,516 KB
testcase_29 AC 354 ms
151,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define array2(type, x, y) array<array<type, y>, x>
#define vector2(type) vector<vector<type> >
#define out(...) printf(__VA_ARGS__)

int dxy[] = {0, 1, 0, -1, 0};

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/

int N,K;
int DP[300][90000];
int MOD = 1e9 + 7;

void solve() {
    cin>>N>>K;
    REP(i,N)cin.ignore();
    
    REP(i,N)REP(j,K+1)DP[i][j]=0;
    DP[0][0]=1;
    FOR(i,1,N) {
        int sum = 0;
        REP(j,K+1) {
            DP[i][j] = DP[i-1][j] + sum;
            DP[i][j] %= MOD;
            sum += DP[i-1][j];
            if (j>=i) {
                sum += MOD - DP[i-1][j-i];
            }
            sum %= MOD;
        }
    }
    int ans = 0;
    REP(j,K+1) {
        ans += DP[N-1][j];
        ans %= MOD;
    }
    
    cout << ans << endl;
}
0