結果

問題 No.118 門松列(2)
ユーザー Zu_rinZu_rin
提出日時 2020-09-11 14:34:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 746 bytes
コンパイル時間 2,387 ms
コンパイル使用メモリ 76,612 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-26 21:21:32
合計ジャッジ時間 3,044 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, j, a;
	cin >> num;
	vector<ll> d(101, 0);
	vector<vector<ll>> dp(3, vector<ll>(101, 0));
	rep(i, num) {
		cin >> a;
		d[a]++;
	}
	rep(i, 100)
		dp[0][i + 1] += dp[0][i] + d[i + 1];
	for(i = 1; i < 3; i++) {
		for (j = 1; j <= 100; j++) {
			dp[i][j] = dp[i - 1][j - 1] * d[j] + dp[i][j - 1];
		}
	}
	cout << dp[2][100] % MOD << "\n";
	return 0;
}
0