結果

問題 No.269 見栄っ張りの募金活動
ユーザー ctyl_0ctyl_0
提出日時 2015-10-06 01:34:02
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 23 ms / 5,000 ms
コード長 1,303 bytes
コンパイル時間 635 ms
コンパイル使用メモリ 89,196 KB
実行使用メモリ 19,152 KB
最終ジャッジ日時 2023-09-23 01:13:00
合計ジャッジ時間 1,586 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 10 ms
8,800 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 23 ms
19,152 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 4 ms
5,008 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 4 ms
4,616 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 8 ms
8,260 KB
testcase_19 AC 4 ms
4,608 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define var auto
#define mod 1000000007
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main() {
    // source code
    int N = inputValue(); // 人数
    int S = inputValue(); // 合計の寄付金
    int K = inputValue(); // 直前の人との差額
    
    S -= K * N * (N - 1) / 2; // デフォルトで必要な寄付金を引く
    if (S < 0) {
        output(0, 0);
        return 0;
    }
    
    vector<vector<ll>> dp(N, vector<ll>(S + 1, 0));
    
    rep(i, N){
        dp[i][0] = 1;
    }
    
    rep(i, N){
        repd(j, 1, S + 1){
            if (j - (N - i) >= 0) dp[i][j] = (dp[i][j] + dp[i][j - (N - i)]) % mod ;
            if (i - 1 >= 0) dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
        }
    }
    
    output(dp[N - 1][S], 0);
    
    return 0;
}
0