結果

問題 No.269 見栄っ張りの募金活動
ユーザー 158b158b
提出日時 2021-07-03 21:07:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 1,697 bytes
コンパイル時間 2,960 ms
コンパイル使用メモリ 160,548 KB
実行使用メモリ 12,040 KB
最終ジャッジ日時 2023-09-13 02:40:02
合計ジャッジ時間 4,154 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 11 ms
11,448 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 12 ms
12,040 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 9 ms
10,060 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 6 ms
7,248 KB
testcase_14 AC 11 ms
12,000 KB
testcase_15 AC 7 ms
8,180 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 7 ms
9,552 KB
testcase_19 AC 4 ms
7,444 KB
testcase_20 AC 5 ms
6,240 KB
testcase_21 AC 9 ms
10,596 KB
testcase_22 AC 4 ms
5,752 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 7 ms
8,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
#include <iomanip>
#include <cmath>
#include <atcoder/all>
using namespace std;
using namespace atcoder;

//#define __int64 long long
//#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;


int n,s,k;
int dp[20010][110];
int dpBox, dpBall;

void print2D(int a[][110]){
    rep(i,dpBall+1){
        rep(j,dpBox+1){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
}

int main(){
    cin >> n >> s >> k;

    dpBall = s - (n * (n+1) / 2 - n) * k;
    dpBox =  n;
    // cout << "dpBall:" << dpBall << endl;
    /*
    rep(i, dpBall+1){
        dp[i][0] = 1;
    }
    rep(i, dpBox+1){
        dp[0][i] = 1;
    }
    */
   dp[0][0] = 1;

    //print2D(dp);

    for(int balli=0; balli<=dpBall; balli++){
        for(int boxi=1; boxi<=dpBox; boxi++){
            // dp[balli][boxi] = dp[balli][boxi-1] + dp[max(0, balli-boxi)][boxi];
            // dp[balli][boxi] %= Modd;

            if(balli-boxi >= 0){
                dp[balli][boxi] = dp[balli][boxi-1] + dp[max(0, balli-boxi)][boxi];
                dp[balli][boxi] %= Modd;
            }else{
                dp[balli][boxi] = dp[balli][boxi-1];
            }
        }
    }

    //print2D(dp);

    if(dpBall < 0){
        cout << 0 << endl;
    }else{
        cout << dp[dpBall][dpBox] << endl;
    }
    
    return 0;
}
0