結果

問題 No.269 見栄っ張りの募金活動
ユーザー ともきともき
提出日時 2015-10-12 01:58:45
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 3,837 bytes
コンパイル時間 987 ms
コンパイル使用メモリ 119,784 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-28 12:32:49
合計ジャッジ時間 2,127 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cassert>

#include <unordered_set>
#include <unordered_map>
#include <random>
#include <thread>
#include <chrono>

using namespace std;

#define int long long
#define let const auto
#define var auto

#define all(c) c.begin(), c.end()
#define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x) 
#endif

typedef complex<double> point;

template <typename T>
vector<T> make_vector1(size_t n){
    return vector<T>(n);
}
template <typename T>
vector<T> make_vector1(size_t n, T ini){
    return vector<T>(n, ini);
}
template <typename T>
vector<vector<T> > make_vector2(size_t n1, size_t n2){
    return vector<vector<T> >(n1, make_vector1<T>(n2));
}
template <typename T>
vector<vector<T> > make_vector2(size_t n1, size_t n2, T ini){
    return vector<vector<T> >(n1, make_vector1<T>(n2, ini));
}
template <typename T>
vector<vector<vector<T> > > make_vector3(size_t n1, size_t n2, size_t n3){
    return vector<vector<vector<T> > >(n1, make_vector2<T>(n2, n3));
}
template <typename T>
vector<vector<vector<T> > > make_vector3(size_t n1, size_t n2, size_t n3, T ini){
    return vector<vector<vector<T> > >(n1, make_vector2<T>(n2, n3, ini));
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    for(auto it = v.begin(); it != v.end(); ++it){
        if(it != v.begin()){
            os << ",";
        }
        os << *it;
    }
    return os << "}";
}
template<typename T>
void isort(std::vector<T>& v, std::function<bool(T,T)> comp=less<T>()){
    sort(v.begin(), v.end(), comp);
}
template<typename T>
std::vector<T> sort(std::vector<T> v, std::function<bool(T,T)> comp=less<T>()){
    isort(v);
    return v;
}
template<typename T1, typename T2>
std::vector<T2> rmap(const std::vector<T1>& v, std::function<T2(T1)> f){
    std::vector<T2> t; t.reserve(v.size());
    for(const auto& i: v) t.push_back(f(i));
    return t;
}
std::vector<std::string> split(std::string str, char delim){
    std::vector<std::string> res;
    size_t current = 0, found;
    while((found = str.find_first_of(delim, current)) != std::string::npos){
        res.push_back(std::string(str, current, found - current));
        current = found + 1;
    }
    res.push_back(std::string(str, current, str.size() - current));
    return res;
}
string join(const std::vector<string>& v, string delim){
    string ret = "";
    for(auto it = v.begin(); it != v.end(); ++it){
        if(it != v.begin()){
            ret += delim;
        }
        ret += *it;
    }
    return ret;
}



signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    const long long mod = 1000000007;
    int n,s,k;
    cin >> n >> s >> k;

    auto dp = make_vector1<int>(s+1);
    dp[0] = 1;
    for(int i=0; i<n; i++){
        auto next = make_vector1<int>(s+1);
        auto add = [&](int i, int v){
            if(0 <= i && i < next.size()){
                next[i] += v;
                next[i] %= mod;
            }
        };
        if(i == 0) {
            for(int p=0; p*n<=s; p++){
                add(p*n, 1);
            }
        } else {
            for(int l=k*(n-i); l<=s; l++){
                add(l, dp[l-k*(n-i)]);
                add(l, next[l-(n-i)]);
            }
        }
        dp.swap(next);
    }
    cout << dp.back() << endl;
    return 0;
}
0