結果

問題 No.3046 yukicoderの過去問
ユーザー zelnyokzelnyok
提出日時 2019-06-29 11:30:56
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,096 bytes
コンパイル時間 1,589 ms
コンパイル使用メモリ 97,496 KB
実行使用メモリ 14,788 KB
最終ジャッジ日時 2023-09-14 23:05:43
合計ジャッジ時間 5,421 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 116 ms
9,788 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 48 ms
9,608 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()
#define MOD 1000000007

signed main() {
	int k,n;
	std::cin >> k >> n;
	std::vector<int> x(n);
	rep(i,n) std::cin >> x[i];
	std::map<int,int> dp;
	dp[0] = 1;
	for(auto& i:dp) {
		for(auto& j:x) {
			int next = i.first+j;
			if(next<=k) dp[next] = (dp[next] + i.second)%MOD;
		}
	}
	print(dp[k]);
	return 0;
}

0