結果

問題 No.269 見栄っ張りの募金活動
ユーザー daikiti10915465daikiti10915465
提出日時 2020-06-05 22:06:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 5,000 ms
コード長 1,803 bytes
コンパイル時間 1,474 ms
コンパイル使用メモリ 168,824 KB
実行使用メモリ 11,472 KB
最終ジャッジ日時 2023-08-22 15:40:02
合計ジャッジ時間 2,634 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 9 ms
6,732 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 19 ms
11,472 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 3 ms
4,396 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 3 ms
4,756 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 4 ms
4,588 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 7 ms
6,264 KB
testcase_19 AC 4 ms
4,380 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,376 KB
testcase_24 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(int i=int(n-1);i>=0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=300000;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}

//https://drken1215.hatenablog.com/entry/2018/01/16/222843
//////////////////////////////////////


int main(){
    int n,s,k;
    cin>>n>>s>>k;
    int atleast=k*n*(n-1)/2;
    
    s-=atleast;
    ll ans=0;
    if(s<0){
        cout<<ans<<endl;
        return 0;
    }
    else if(s==0){
        cout<<1<<endl;
        return 0;
    }
    int all=s;
    vvi dp(all+1,vi(n+1));
    dp[0][0]=1;//初期化は[i][i]への遷移を意識
    arep(i,0,all+1){//出来れば文字は逆の方がいい
        arep(j,1,n+1){
            
            if(i-j>=0)dp[i][j]=dp[i][j-1]+dp[i-j][j];//通常
            else dp[i][j]=dp[i][j-1];//もう全部に1個ずつは足りない。
            dp[i][j]%=mod;
        }
    }
    cout<<dp[all][n]<<endl;
    return 0;
}
0