結果

問題 No.269 見栄っ張りの募金活動
ユーザー togatogatogatoga
提出日時 2015-08-22 07:49:00
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 900 bytes
コンパイル時間 1,106 ms
コンパイル使用メモリ 143,844 KB
実行使用メモリ 19,000 KB
最終ジャッジ日時 2023-09-25 15:54:51
合計ジャッジ時間 13,982 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
19,000 KB
testcase_01 AC 5 ms
11,912 KB
testcase_02 AC 5 ms
11,916 KB
testcase_03 AC 28 ms
12,088 KB
testcase_04 TLE -
testcase_05 AC 6 ms
11,896 KB
testcase_06 AC 5 ms
11,908 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define mp       make_pair
#define mt	 make_tuple
#define pb       push_back
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    pair<int,int>      pii;
typedef    pair<long,long>    pll;

const int INF=1<<29;
const double EPS=1e-9;
const int MOD = 1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int N,S,K;
int dp[110][20010];
int memo(int pos, int sum){
  if (sum > S){
    return 0;
  }
  if (pos == N - 1){
    return 1;
  }
  if (dp[pos][sum] >= 0){
    return dp[pos][sum];
  }
  int res = 0;
  for (int i = 0; i*(N - pos) <= S; i++){
    res += memo(pos + 1, sum + i * (N - pos));
    res %= MOD;
  }
  return dp[pos][sum] = res;
}
int main(){
  cin >> N >> S >> K;
  memset(dp, -1, sizeof(dp));
  S -= N * (N - 1) / 2 * K;
  cout << memo(0, 0) << endl;
  return 0;
}
0