結果

問題 No.3046 yukicoderの過去問
ユーザー zelnyokzelnyok
提出日時 2019-06-29 11:33:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,115 bytes
コンパイル時間 949 ms
コンパイル使用メモリ 105,800 KB
実行使用メモリ 13,196 KB
最終ジャッジ日時 2023-09-14 23:07:39
合計ジャッジ時間 4,625 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
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::unordered_map<int,int> dp;
	dp[0] = 1;
	for(auto& i:dp) {
		for(auto& j:x) {
			int next = i.first+j;
			if(next>k) break;
			dp[next] = (dp[next] + i.second)%MOD;
		}
	}
	print(dp[k]);
	return 0;
}

0