結果

問題 No.269 見栄っ張りの募金活動
ユーザー nebukuro09nebukuro09
提出日時 2016-12-28 20:26:49
言語 D
(dmd 2.107.1)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 925 bytes
コンパイル時間 1,561 ms
コンパイル使用メモリ 91,560 KB
実行使用メモリ 20,264 KB
最終ジャッジ日時 2023-09-03 00:17:32
合計ジャッジ時間 18,232 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 16 ms
4,384 KB
testcase_04 AC 3,681 ms
9,460 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 TLE -
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 6 ms
10,292 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 1,643 ms
4,380 KB
testcase_12 AC 6 ms
9,508 KB
testcase_13 AC 742 ms
4,800 KB
testcase_14 AC 497 ms
4,380 KB
testcase_15 AC 1,048 ms
5,564 KB
testcase_16 AC 5 ms
7,648 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 1,114 ms
12,600 KB
testcase_19 AC 355 ms
5,012 KB
testcase_20 AC 232 ms
4,380 KB
testcase_21 AC 804 ms
4,384 KB
testcase_22 AC 256 ms
4,384 KB
testcase_23 AC 7 ms
4,380 KB
testcase_24 AC 639 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;


void main() {
    immutable long MOD = 10^^9+7;

    int N, S, K;
    scanf("%d %d %d", &N, &S, &K);

    auto dp = new long[][](N, S+1);
    foreach (i; 0..N) foreach (j; 0..S+1) dp[i][j] = 0;

    foreach (i; 0..S+1) {
        auto s = N * (N-1) * K / 2 + i * N;
        if (s > S)
            break;
        dp[0][s] = 1;
    }

    foreach (i; 0..N-1) {
        foreach (j; 0..S+1) {
            if (dp[i][j] == 0)
                continue;
            foreach (x; 0..S+1) { // (i+1)人目が(K+x)円増やす
                auto incr = (N-i-1) * x;
                if (j + incr > S)
                    break;
                (dp[i+1][j+incr] += dp[i][j]) %= MOD;
            }
        }
    }

    dp[N-1][S].writeln;
}
0