結果

問題 No.269 見栄っ張りの募金活動
ユーザー kw_ckw_c
提出日時 2023-06-16 11:31:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 5,000 ms
コード長 4,067 bytes
コンパイル時間 2,088 ms
コンパイル使用メモリ 204,144 KB
実行使用メモリ 19,360 KB
最終ジャッジ日時 2023-09-06 11:07:00
合計ジャッジ時間 3,280 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 10 ms
9,484 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 25 ms
19,360 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 12 ms
10,236 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 4 ms
4,884 KB
testcase_12 AC 9 ms
8,528 KB
testcase_13 AC 4 ms
5,092 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 4 ms
4,960 KB
testcase_16 AC 9 ms
8,132 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 16 ms
13,316 KB
testcase_19 AC 5 ms
5,752 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 3 ms
4,376 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 3 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = n-1; i >= (0); --i)
#define IO ios::sync_with_stdio(0),cin.tie(0);
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front
#define eb emplace_back
#define ef emplace_front
#define bpop(x) __builtin_popcount(x)
#define bpopll(x) __builtin_popcountll(x)

/* using mint = modint1000000007; */ 
/* using mint = static_modint<998244353>; */

/* using mint = modint; */
/* mint::set_mod(mod); */

template<class T>
bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template<class T>
bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
void print_imp() {}
template<class First, class... Rest>
void print_imp(First f, Rest... r) { cout<<f; if (sizeof...(r)) cout<<" "; print_imp(r...); }
template<class... Args>
void print(Args... args) { print_imp(args...); cout << endl; }
template<class T>
void print_pair(vector<T> &v) { for (auto [a,b] : v) print(a, b); }
template<class T>
void print_vec(vector<T> &v) { rep(i, v.size()) {cout << v[i]; if (i == v.size()-1) cout << endl; else cout << " ";} }
template<class T>
void print_mint_vec(vector<T> &v) { for (auto e : v) cout << e.val() << " "; cout << endl; }
template<class T>
void print_mat(vector<vector<T>> &m) { for (auto v : m) print_vec(v); }
template<class T>
void print_mint_mat(vector<vector<T>> &m) { for (auto v : m) print_mint_vec(v); }
template<class T>
void print_bit(T s, int n) { rep(i, n) {if (s>>i&1) cout<<1; else cout<<0;} cout<<endl; }
void print_double(double x) { cout << fixed << setprecision(15) << x << endl; }

template<class T>
using min_pq = priority_queue<T, vector<T>, greater<T>>;
template<class T>
using vt = vector<T>;
template<class T>
using vvt = vt<vt<T>>;
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;

const ll MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 4e18;
const double PI = 3.14159265358979323846;

/*
- comb                          modintのnCk,nPk
- matrix                        行列累乗
- RMQ/RMAQ_min/max              lazy_segtree 区間加算/変更、区間最小値/最大値取得
- RSQ/RSAQ                      lazy_segtree 区間加算/変更、区間和取得
- Eratosthenes                  高速素因数分解可能なエラトステネスのふるい
- dydx, dydx8                   dy,dx={右,下,左,上}
- grid_continue                 if (i < 0 || j < 0 || i >= h || j >= w) continue;
- Pascal                        パスカルの三角形
- Graph                         グラフ関連のライブラリ
    - dijkstra                  ダイクストラ法
    - bellman_ford              ベルマンフォード、負のサイクル検出
    - topological_sort          トポロジカルソート
    - find_cycle_directed       有向グラフのサイクル検出
    - bfs01                     01-BFS
    - tree_diameter             木の直径
    - euler_tour                オイラーツアー
    - build_LCA, get_LCA        LCA
    - build_tree_dist           木の根からの距離
    - dfs_temp                  DFSのためのテンプレート

    - init_tree_from_parents    親頂点配列でGraph初期化
    - init_graph_from_grid      グリッド文字列からGraph初期化
*/

void solve() {
    int n, s, k;
    cin >> n >> s >> k;

    vector dp(n+1, vt<ll>(s+1));
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= s; j++) {
            int nj1 = j-(n-i)*k, nj2 = j-(n-i);
            if (i-1 >= 0 && nj1 >= 0) dp[i][j] += dp[i-1][nj1];
            dp[i][j] %= MOD;
            if (nj2 >= 0) dp[i][j] += dp[i][nj2];
            dp[i][j] %= MOD;
        }
    }
    /* print_mat(dp); */
    print(dp[n-1][s]);
}

int main() {
    IO
    /* int t; cin >> t; rep(_, t) solve(); */
    solve();
    return 0;
}
0