結果

問題 No.444 旨味の相乗効果
ユーザー はむこはむこ
提出日時 2016-08-26 06:25:13
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 740 bytes
コンパイル時間 1,194 ms
コンパイル使用メモリ 163,436 KB
実行使用メモリ 22,912 KB
最終ジャッジ日時 2024-04-28 12:33:01
合計ジャッジ時間 4,217 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; 
static const long long mo = 1e9+7;

int main(void) {
    ll n, c; cin >> n >> c;
    vll a(n); rep(i, a.size()) cin >> a[i];

    static vvll dp(c+1, vll(n, 0));
    rep(j, n) dp[0][j] = 1;

    rep(i, c) rep(j, n) repi(h, j, n) 
        (dp[i+1][h] += dp[i][j] * a[j]) %= mo;
    ll ret = dp[c][n-1];

    rep(i, n) {
        ll tmp = 1;
        rep(j, c) 
            (tmp *= a[i]) %= mo;
        (ret -= tmp) %= mo;
    }
    cout << (ret + mo) % mo << endl;
    return 0;
}
0