- #include <iostream>
- using namespace std;
- const int N = 30;
- int d[N][N][N];
- int n, m, limit;
- int tim[N];
- int main()
- {
- int i, j, k;
- //freopen("rockers.in", "r", stdin);
- //freopen("rockers.out", "w", stdout);
- scanf("%d%d%d",&n, &limit, &m);
- for(i = 1; i <= n; i++)
- scanf("%d",&tim[i]);
- int ans = 0;
- for(i = 1; i <= m; i++)
- for(j = 0; j <= limit; j++)
- for(k = 0; k <= n; k++){
- for(int t = k + 1; t <= n; t++)
- {
- if(j + tim[t] <= limit)
- d[i][j+tim[t]][t] = max(d[i][j][k] + 1 ,d[i][j+tim[t]][t]);
- else d[i+1][tim[t]][t] = max(d[i+1][tim[t]][t], d[i][j][k] + 1);
- }
- ans = max(ans, d[i][j][k]);
- }
- printf("%d/n",ans);
- scanf("%d",&n);
- return 0;
- }
USACO 3.4 Rockers
最新推荐文章于 2022-07-04 15:15:42 发布