Posted on 2009-04-29 15:19
superman 阅读(73)
评论(0) 编辑 收藏 引用 所属分类:
USACO
1 #include <iostream>
2
3 using namespace std;
4
5 int n, m, c[50], f[2000002];
6
7 int main()
8 {
9 freopen("stamps.in", "r", stdin);
10 freopen("stamps.out", "w", stdout);
11
12 cin >> n >> m;
13 for (int i = 0; i < m; i++)
14 cin >> c[i];
15
16 sort(c, c + m);
17
18 for (int i = 1; i <= 2000000; i++)
19 {
20 f[i] = INT_MAX;
21 for (int j = 0; j < m; j++)
22 if (i - c[j] >= 0)
23 f[i] <?= f[i - c[j]] + 1;
24 if (f[i] > n)
25 {
26 cout << i - 1 << endl;
27 return 0;
28 }
29 }
30 cout << 2000000 << endl;
31
32 return 0;
33 }
34