結果

問題 No.269 見栄っ張りの募金活動
ユーザー pleiades_223pleiades_223
提出日時 2023-03-21 13:27:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 39 ms / 5,000 ms
コード長 2,889 bytes
コンパイル時間 4,254 ms
コンパイル使用メモリ 265,304 KB
実行使用メモリ 19,532 KB
最終ジャッジ日時 2023-10-18 18:23:39
合計ジャッジ時間 6,262 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 4 ms
4,348 KB
testcase_04 AC 16 ms
9,560 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 39 ms
19,532 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 18 ms
10,292 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 6 ms
5,080 KB
testcase_12 AC 14 ms
8,708 KB
testcase_13 AC 7 ms
5,276 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 7 ms
5,012 KB
testcase_16 AC 13 ms
8,180 KB
testcase_17 AC 4 ms
4,348 KB
testcase_18 AC 25 ms
13,248 KB
testcase_19 AC 8 ms
5,804 KB
testcase_20 AC 3 ms
4,348 KB
testcase_21 AC 3 ms
4,348 KB
testcase_22 AC 4 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
testcase_24 AC 3 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
using ll = long long;
using vi = vector<int>;
using vll = vector<long long>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vcc = vector<char>;
using vvcc = vector<vcc>;
using mii = map<int,int>;
using mll = map<ll,ll>;
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); i++)
#define rreps(i, a, n) for (ll i = (a); i >= (ll)(n); i--)
#define rep(i, n) reps(i, 0, n)
#define repd(i, n) reps(i, 1, n + 1)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rrepd(i,n) for(ll i=n;i>=1;i--)
#define vrep(i,x) for(auto i:x)
#define vsrep(i,x) for(auto &i:x)
#define vinsert(x,a) x.insert(upper_bound(x.begin(),x.end(),a),a)
#define vin(x) rep(i,x.size())cin >> x[i];
#define vout(x) rep(i,x.size())cout << x[i] << ( i!=x.size()-1 ? ' ' : '\n' );
template<typename T> auto vec_sum(T x){ll ans=0;rep(i,x.size())ans+=x[i];return ans;}
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end());
template<typename T> void yesno(T x){if(x)cout << "Yes" << endl;else cout << "No" << endl;}
template<typename T> inline bool chmin(T &a,T b){
    if(a>b){
        a=b;
        return true;
    }
    return false;
}
template<typename T> inline bool chmax(T &a,T b){
    if(a<b){
        a=b;
        return true;
    }
    return false;
}
#define F first
#define S second
template<typename T> using vc = vector<T>;
template<typename T> using vvc = vector<vector<T>>;
template<typename T,typename Y> using uomap = unordered_map<T,Y>;
template<typename T> using uoset = unordered_set<T>;
template<typename T> using revpriority_queue = priority_queue<T,vector<T>,greater<T>>;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
int ddx[8] = { -1,0,1,1,1,0,-1,-1 };
int ddy[8] = { 1,1,1,0,-1,-1,-1,0 };
string taka="Takahashi",aoki="Aoki";
const int inf = 1073741824;//2^30
const ll llinf = 1152921504606846976;//2^60
const long double lpi = 3.141592653589793238;
const double pi = 3.141592653589793;
ll mod = 1000000007;
//ll mod = 998244353;
//using mint = modint1000000007;
//using mint = modint998244353;

int main(){
    //cout << fixed << setprecision(16);
    //ifstream in("input.txt");
    //cin.rdbuf(in.rdbuf());
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    ll n,s,k;
    cin >> n >> s >> k;
    vvll dp(n+1,vll(s+1,0));
    rep(i,s+1)if(i*n<=s)dp[1][i*n]=1;
    reps(i,1,n){
        rep(j,s+1){
            if(j-(n-i)*k>=0){
                dp[i+1][j]=dp[i][j-(n-i)*k];
            }
            if(j-(n-i)>=0){
                dp[i+1][j]+=dp[i+1][j-(n-i)];
            }
            dp[i+1][j]%=mod;
        }
    }
    cout << dp[n][s];
}
0