結果

問題 No.137 貯金箱の焦り
ユーザー Min_25Min_25
提出日時 2015-12-08 22:12:13
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 179 ms / 5,000 ms
コード長 956 bytes
コンパイル時間 428 ms
コンパイル使用メモリ 62,452 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 11:52:40
合計ジャッジ時間 1,835 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 3 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 179 ms
5,376 KB
testcase_13 AC 12 ms
5,376 KB
testcase_14 AC 81 ms
5,376 KB
testcase_15 AC 75 ms
5,376 KB
testcase_16 AC 69 ms
5,376 KB
testcase_17 AC 23 ms
5,376 KB
testcase_18 AC 64 ms
5,376 KB
testcase_19 AC 74 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 36 ms
5,376 KB
testcase_22 AC 5 ms
5,376 KB
testcase_23 AC 5 ms
5,376 KB
testcase_24 AC 17 ms
5,376 KB
testcase_25 AC 46 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void solve()’:
main.cpp:27:20: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |     rep(i, N) scanf("%d", &A[i]), s += A[i];
      |               ~~~~~^~~~~~~~~~~~~

ソースコード

diff #

#include <cstdio>
#include <cassert>
#include <cstring>
#include <ctime>

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>

#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep3(i, m, n) for (int i = int(m); i < int(n); ++i)

using namespace std;
using int64 = long long;

const int64 MOD = 1234567891;

int A[50];
int64 poly[50010];

void solve() {
  int64 N, M;
  while (~scanf("%lld %lld", &N, &M)) {
    int64 s = 0;
    rep(i, N) scanf("%d", &A[i]), s += A[i];
    poly[0] = 1;
    int64 t = 1;
    while (M) {
      fill(poly + t, poly + s + t, 0);
      rep(i, N) {
        for(int j = t - 1; j >= 0; --j) {
          if (poly[j]) (poly[j + A[i]] += poly[j]) %= MOD;
        }
        t += A[i];
      }
      int p = M & 1;
      M >>= 1;
      t = (t + 1 - p) >> 1;
      rep(i, t) poly[i] = poly[2 * i + p];
    }
    printf("%lld\n", poly[0]);
  }
}

int main() {
  solve();
  return 0;
}
0